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

* argument for set-context is optional, so removing the assignment of args[0] to Name.
  Already conditionally the args[0] is assigned if passed

Change-Id: Ib3232fc19cbaa2cf3dd14b46e910def5d20fed52
This commit is contained in:
Yasin, Siraj (SY495P) 2020-03-02 15:17:10 +00:00
parent f66f94dc80
commit c26c6e5ac1

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 {