Update config generator

This commit is contained in:
Ryan McGuire 2023-12-29 09:22:19 -05:00
parent 5c2a9513a4
commit ea0157a997
3 changed files with 18 additions and 6 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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"`
}