Merge "[#74] - args for set-context is optional"

This commit is contained in:
Zuul 2020-03-02 19:29:16 +00:00 committed by Gerrit Code Review
commit af43008ca2

View File

@ -60,17 +60,16 @@ func NewCmdConfigSetContext(rootSettings *environment.AirshipCTLSettings) *cobra
Example: setContextExample,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
o.Name = args[0]
nFlags := cmd.Flags().NFlag()
if nFlags == 0 {
fmt.Fprintf(cmd.OutOrStdout(), "Context %q not modified. No new options provided.\n", o.Name)
return nil
}
if len(args) == 1 {
//context name is made optional with --current flag added
o.Name = args[0]
}
if o.Name != "" && nFlags == 0 {
fmt.Fprintf(cmd.OutOrStdout(), "Context %q not modified. No new options provided.\n", o.Name)
return nil
}
modified, err := config.RunSetContext(o, rootSettings.Config(), true)
if err != nil {