@@ -19,13 +19,15 @@ import (
1919const (
2020 profileArg = "PROFILE"
2121
22- noSetFlag = "no-set"
23- fromEmptyProfile = "empty"
22+ noSetFlag = "no-set"
23+ ignoreExistingFlag = "ignore-existing"
24+ fromEmptyProfile = "empty"
2425)
2526
2627type inputModel struct {
2728 * globalflags.GlobalFlagModel
2829 NoSet bool
30+ IgnoreExisting bool
2931 FromEmptyProfile bool
3032 Profile string
3133}
@@ -34,12 +36,13 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
3436 cmd := & cobra.Command {
3537 Use : fmt .Sprintf ("create %s" , profileArg ),
3638 Short : "Creates a CLI configuration profile" ,
37- Long : fmt .Sprintf ("%s\n %s\n %s\n %s\n %s" ,
39+ Long : fmt .Sprintf ("%s\n %s\n %s\n %s\n %s\n %s " ,
3840 "Creates a CLI configuration profile based on the currently active profile and sets it as active." ,
3941 `The profile name can be provided via the STACKIT_CLI_PROFILE environment variable or as an argument in this command.` ,
4042 "The environment variable takes precedence over the argument." ,
4143 "If you do not want to set the profile as active, use the --no-set flag." ,
4244 "If you want to create the new profile with the initial default configurations, use the --empty flag." ,
45+ "If you want to create the new profile and ignore the error for an already existing profile, use the --ignore-existing flag." ,
4346 ),
4447 Args : args .SingleArg (profileArg , nil ),
4548 Example : examples .Build (
@@ -56,7 +59,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5659 return err
5760 }
5861
59- err = config .CreateProfile (params .Printer , model .Profile , ! model .NoSet , model .FromEmptyProfile )
62+ err = config .CreateProfile (params .Printer , model .Profile , ! model .NoSet , model .IgnoreExisting , model . FromEmptyProfile )
6063 if err != nil {
6164 return fmt .Errorf ("create profile: %w" , err )
6265 }
@@ -85,6 +88,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
8588
8689func configureFlags (cmd * cobra.Command ) {
8790 cmd .Flags ().Bool (noSetFlag , false , "Do not set the profile as the active profile" )
91+ cmd .Flags ().Bool (ignoreExistingFlag , false , "Suppress the error it the profile exists already" )
8892 cmd .Flags ().Bool (fromEmptyProfile , false , "Create the profile with the initial default configurations" )
8993}
9094
@@ -103,6 +107,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
103107 Profile : profile ,
104108 FromEmptyProfile : flags .FlagToBoolValue (p , cmd , fromEmptyProfile ),
105109 NoSet : flags .FlagToBoolValue (p , cmd , noSetFlag ),
110+ IgnoreExisting : flags .FlagToBoolValue (p , cmd , ignoreExistingFlag ),
106111 }
107112
108113 p .DebugInputModel (model )
0 commit comments