Skip to content

Commit

Permalink
Cleaning up config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gwendolyngoetz committed Oct 27, 2022
1 parent 3fe0fe4 commit d642263
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cmd/prompt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
)

type Config struct {
ShowVersion bool
ShowHostname bool
ShowPythonVirtualEnvText bool
ShowVersion bool
ShowHostname bool
ShowPythonVEnvName bool
}

var (
Expand Down Expand Up @@ -61,7 +61,7 @@ func buildPrompt(config *Config) string {
if computer.IsPythonVirtualEnv() {
venvName := ""

if config.ShowPythonVirtualEnvText {
if config.ShowPythonVEnvName {
venvName = computer.GetPythonVirtualEnv()
}

Expand Down Expand Up @@ -91,22 +91,24 @@ func getChangesIcon() string {
return ""
}

func main() {
showVersion := flag.Bool("version", false, "Show version")
showHostname := flag.Bool("showHostname", false, "Show Hostname")
showPythonVirtualEnvText := flag.Bool("showPythonVirtualEnvText", false, "Show Python Virtual Env Text")
func loadConfig() *Config {
config := Config{}
flag.BoolVar(&config.ShowVersion, "version", false, "Show version")
flag.BoolVar(&config.ShowHostname, "showHostname", false, "Show Hostname")
flag.BoolVar(&config.ShowPythonVEnvName, "showPythonVEnvName", false, "Show Python Virtual Env Name")
flag.Parse()

if *showVersion {
return &config
}

func main() {
config := loadConfig()

if config.ShowVersion {
fmt.Println(Version)
return
}

config := Config{
ShowHostname: *showHostname,
ShowPythonVirtualEnvText: *showPythonVirtualEnvText,
}

promptString := buildPrompt(&config)
promptString := buildPrompt(config)
fmt.Println(promptString)
}

0 comments on commit d642263

Please sign in to comment.