Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Koustavd18 committed Oct 6, 2024
1 parent 07ae10f commit 51f6cc3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,25 @@ func main() {

cli.CompletionOptions.HiddenDefaultCmd = true

// create a default profile if file does not exist
if _, err := config.ReadConfigFromFile(); os.IsNotExist(err) {
// create a default profile if file does not exist
if previousConfig, err := config.ReadConfigFromFile(); os.IsNotExist(err) {
conf := config.Config{
Profiles: map[string]config.Profile{"demo": defaultInitialProfile()},
DefaultProfile: "demo",
}
config.WriteConfigToFile(&conf)
} else {
// updates the demo profile for existing users
_, exists := previousConfig.Profiles["demo"]
if exists {
conf := config.Profile{
URL: "http://demo.parseable.com",
Username: "admin",
Password: "admin",
}
previousConfig.Profiles["demo"] = conf
config.WriteConfigToFile(previousConfig)
}
}

err := cli.Execute()
Expand Down

0 comments on commit 51f6cc3

Please sign in to comment.