diff --git a/cmd/init.go b/cmd/init.go index 8f006bc98..6d7f1a911 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -10,6 +10,7 @@ import ( "github.com/qri-io/dataset" "github.com/qri-io/ioes" "github.com/qri-io/qri/lib" + "github.com/qri-io/varName" "github.com/spf13/cobra" ) @@ -79,7 +80,7 @@ func (o *InitOptions) Run() (err error) { if err != nil { return err } - suggestDataset := filepath.Base(pwd) + suggestDataset := varName.CreateVarNameFromString(filepath.Base(pwd)) // Process flags for inputs, prompt for any that were not provided. var dsName, dsFormat string diff --git a/cmd/save.go b/cmd/save.go index 4f12a963e..af09bf369 100644 --- a/cmd/save.go +++ b/cmd/save.go @@ -105,7 +105,7 @@ type SaveOptions struct { // Complete adds any missing configuration that can only be added just before calling Run func (o *SaveOptions) Complete(f Factory, args []string) (err error) { o.Ref, err = GetDatasetRefString(f, args, 0) - o.IsLinkedRef, _ = GetLinkedFilesysRef() + _, o.IsLinkedRef = GetLinkedFilesysRef() if o.IsLinkedRef { // Determine format of the body. diff --git a/cmd/status.go b/cmd/status.go index d5690f8bc..f87ae4c76 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -46,7 +46,7 @@ type StatusOptions struct { // Complete adds any missing configuration that can only be added just before calling Run func (o *StatusOptions) Complete(f Factory, args []string) (err error) { var ok bool - ok, o.Selection = GetLinkedFilesysRef() + o.Selection, ok = GetLinkedFilesysRef() if !ok { return fmt.Errorf("this is not a linked working directory") } diff --git a/cmd/use.go b/cmd/use.go index 91acae559..7101e98af 100644 --- a/cmd/use.go +++ b/cmd/use.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strings" "github.com/qri-io/ioes" "github.com/qri-io/qri/lib" @@ -138,7 +139,7 @@ func GetDatasetRefString(f Factory, args []string, index int) (string, error) { return args[index], nil } // If in a working directory that is linked to a dataset, use that link's reference. - ok, data := GetLinkedFilesysRef() + data, ok := GetLinkedFilesysRef() if ok { return data, nil } @@ -156,12 +157,12 @@ func GetDatasetRefString(f Factory, args []string, index int) (string, error) { // GetLinkedFilesysRef returns whether the current directory is linked to a dataset in your repo, // and the reference to that dataset. -func GetLinkedFilesysRef() (bool, string) { +func GetLinkedFilesysRef() (string, bool) { data, err := ioutil.ReadFile(QriRefFilename) if err == nil { - return true, string(data) + return strings.TrimSpace(string(data)), true } - return false, "" + return "", false } // DefaultSelectedRefList returns the list of currently selected dataset references