// NewUseCommand creates a new command to set the current context
NewUseCommand creates a new command to set the current context
// NewUseCommand creates a new command to set the current context
func NewUseCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		Connection:     f.Connection,
		IO:             f.IOStreams,
		Logger:         f.Logger,
		localizer:      f.Localizer,
		ServiceContext: f.ServiceContext,
	}
	cmd := &cobra.Command{
		Use:     "use",
		Short:   f.Localizer.MustLocalize("context.use.cmd.shortDescription"),
		Long:    f.Localizer.MustLocalize("context.use.cmd.longDescription"),
		Example: f.Localizer.MustLocalize("context.use.cmd.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			if !opts.IO.CanPrompt() && opts.name == "" {
				return flagutil.RequiredWhenNonInteractiveError("name")
			}
			return runUse(opts)
		},
	}
	flags := contextcmdutil.NewFlagSet(cmd, f)
	flags.AddContextName(&opts.name)
	return cmd
}
func NewUseCommand ( f * factory . Factory ) * cobra . Command { opts := & options { Connection : f . Connection , IO : f . IOStreams , Logger : f . Logger , localizer : f . Localizer , ServiceContext : f . ServiceContext , } 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 ! opts . IO . CanPrompt ( ) && opts . name == " " { return flagutil . RequiredWhenNonInteractiveError ( " " ) } return runUse ( opts ) } , } flags := contextcmdutil . NewFlagSet ( cmd , f ) flags . AddContextName ( & opts . name ) return cmd }
NewUseCommand creates a new command to set the current context
NewUseCommand creates a new command to set the current context