-
Notifications
You must be signed in to change notification settings - Fork 31
feat(config): add ignore-existing for profile create #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,8 +79,8 @@ func GetProfileFromEnv() (string, bool) { | |
| // CreateProfile creates a new profile. | ||
| // If emptyProfile is true, it creates an empty profile. Otherwise, copies the config from the current profile to the new profile. | ||
| // If setProfile is true, it sets the new profile as the active profile. | ||
| // If the profile already exists, it returns an error. | ||
| func CreateProfile(p *print.Printer, profile string, setProfile, emptyProfile bool) error { | ||
| // If the profile already exists and ignoreExisting is false, it returns an error. | ||
| func CreateProfile(p *print.Printer, profile string, setProfile, ignoreExising, emptyProfile bool) error { | ||
| err := ValidateProfile(profile) | ||
| if err != nil { | ||
| return fmt.Errorf("validate profile: %w", err) | ||
|
|
@@ -98,6 +98,15 @@ func CreateProfile(p *print.Printer, profile string, setProfile, emptyProfile bo | |
| // Error if the profile already exists | ||
| _, err = os.Stat(configFolderPath) | ||
| if err == nil { | ||
| if ignoreExising { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should the flag ignoreExisting do? For me it's currently a bit confusing, because I assumed that it's like an overwrite of the existing profile with the same name. Usually when a user runs When I now set the flag |
||
| if setProfile { | ||
| err = SetProfile(p, profile) | ||
| if err != nil { | ||
| return fmt.Errorf("set profile: %w", err) | ||
| } | ||
| } | ||
| return nil | ||
dergeberl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return fmt.Errorf("profile %q already exists", profile) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: typo