// NewUnsetCommand creates a new command to unset services in current command
NewUnsetCommand creates a new command to unset services in current command
// NewUnsetCommand creates a new command to unset services in current command
func NewUnsetCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		f: f,
	}
	cmd := &cobra.Command{
		Use:     "unset",
		Short:   f.Localizer.MustLocalize("context.unset.cmd.shortDescription"),
		Long:    f.Localizer.MustLocalize("context.unset.cmd.longDescription"),
		Example: f.Localizer.MustLocalize("context.unset.cmd.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			if len(opts.services) == 0 {
				return opts.f.Localizer.MustLocalizeError("context.unset.cmd.error.noServices")
			}
			for _, s := range opts.services {
				if !flagutil.IsValidInput(s, servicespec.AllServiceLabels...) {
					return f.Localizer.MustLocalizeError("common.error.args.error.unknownServiceError", localize.NewEntry("ServiceName", s))
				}
			}
			return runUnset(opts)
		},
	}
	flags := contextcmdutil.NewFlagSet(cmd, f)
	flags.AddContextName(&opts.name)
	flags.StringSliceVar(&opts.services, "services", []string{}, "context.unset.flag.services.description")
	return cmd
}
func NewUnsetCommand ( f * factory . Factory ) * cobra . Command { opts := & options { f : f , } cmd := & cobra . Command { Use : " " , Short : f . Localizer . MustLocalize ( " " ) , Long : f . Localizer . MustLocalize ( " " ) , Example : f . Localizer . MustLocalize ( " " ) , Args : cobra . NoArgs , RunE : func ( cmd * cobra . Command , args [ ] string ) error { if len ( opts . services ) == 0 { return opts . f . Localizer . MustLocalizeError ( " " ) } for _ , s := range opts . services { if ! flagutil . IsValidInput ( s , servicespec . AllServiceLabels ... ) { return f . Localizer . MustLocalizeError ( " " , localize . NewEntry ( " " , s ) ) } } return runUnset ( opts ) } , } flags := contextcmdutil . NewFlagSet ( cmd , f ) flags . AddContextName ( & opts . name ) flags . StringSliceVar ( & opts . services , " " , [ ] string { } , " " ) return cmd }
NewUnsetCommand creates a new command to unset services in current command
NewUnsetCommand creates a new command to unset services in current command