// AddContextName adds a flag for setting the name of the context
AddContextName adds a flag for setting the name of the context
// AddContextName adds a flag for setting the name of the context
func (fs *FlagSet) AddContextName(name *string) *flagutil.FlagOptions {
	svcContext, _ := fs.factory.ServiceContext.Load()
	svcContextsMap := svcContext.Contexts
	flagName := "name"
	fs.StringVar(
		name,
		flagName,
		"",
		fs.factory.Localizer.MustLocalize("context.common.flag.name"),
	)
	contextNames := make([]string, 0, len(svcContextsMap))
	for k := range svcContextsMap {
		contextNames = append(contextNames, k)
	}
	_ = fs.cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
		return contextNames, cobra.ShellCompDirectiveNoSpace
	})
	return flagutil.WithFlagOptions(fs.cmd, flagName)
}
func ( fs * FlagSet ) AddContextName ( name * string ) * flagutil . FlagOptions { svcContext , _ := fs . factory . ServiceContext . Load ( ) svcContextsMap := svcContext . Contexts flagName := " " fs . StringVar ( name , flagName , " " , fs . factory . Localizer . MustLocalize ( " " ) , ) contextNames := make ( [ ] string , 0 , len ( svcContextsMap ) ) for k := range svcContextsMap { contextNames = append ( contextNames , k ) } _ = fs . cmd . RegisterFlagCompletionFunc ( flagName , func ( cmd * cobra . Command , _ [ ] string , _ string ) ( [ ] string , cobra . ShellCompDirective ) { return contextNames , cobra . ShellCompDirectiveNoSpace } ) return flagutil . WithFlagOptions ( fs . cmd , flagName ) }
AddContextName adds a flag for setting the name of the context
AddContextName adds a flag for setting the name of the context