diff --git a/cmd/config_generate.go b/cmd/config_generate.go index 8c5f972..6bf6b68 100644 --- a/cmd/config_generate.go +++ b/cmd/config_generate.go @@ -1,6 +1,7 @@ package cmd import ( + "bytes" "fmt" "os" @@ -47,9 +48,12 @@ func runConfigGenerateCmd(cmd *cobra.Command, args []string) { plog.Args("file", configFile)) } else { - c, _ := yaml.Marshal(newConf) + var c bytes.Buffer + enc := yaml.NewEncoder(&c) + enc.SetIndent(2) + enc.Encode(newConf) plog.Info("Suggest running with --write or redirect (> " + configFile + ")") - fmt.Print(string(c)) + fmt.Print(c.String()) } } @@ -96,6 +100,14 @@ func promptConfigSettings(c *config.Config) *config.Config { Show(); err == nil { c.GitlabToken = token } + + if dirMode, err := pterm.DefaultInteractiveConfirm. + WithDefaultValue(true). + WithDefaultText("Open project directories instead of main files (yes for vscode)?"). + Show(); err == nil { + c.Editor.OpenDirectory = dirMode + } + return c } diff --git a/cmd/project_open.go b/cmd/project_open.go index 0053972..97bddd3 100644 --- a/cmd/project_open.go +++ b/cmd/project_open.go @@ -111,7 +111,7 @@ func getEntrypointFile(projectPath string) string { if err := os.Chdir(projectPath); err != nil { return "" } else if conf.Editor.OpenDirectory { - return projectPath + return "." } // Search list of well-known main files diff --git a/internal/config/config.go b/internal/config/config.go index 0d4255d..9251744 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,9 +15,9 @@ type Config struct { } type editorConfig struct { - DisplayName string `yaml:"displanName" json:"displanName"` - Binary string `yaml:"binary" json:"binary"` - OpenFlags string `yaml:"openFlags" json:"openFlags"` + DisplayName string `yaml:"displanName,omitempty" json:"displanName"` + Binary string `yaml:"binary,omitempty" json:"binary"` + OpenFlags string `yaml:"openFlags,omitempty" json:"openFlags"` OpenDirectory bool `yaml:"openDirectory" json:"openDirectory" description:"Don't open well-known files, open directory"` }