// NewCreateCommand creates a new command for creating kafkas.
NewCreateCommand creates a new command for creating kafkas.
// NewCreateCommand creates a new command for creating kafkas .
func NewCreateCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		f: f,
	}
	cmd := &cobra.Command{
		Use:     "create",
		Short:   f.Localizer.MustLocalize("kafka.create.cmd.shortDescription"),
		Long:    f.Localizer.MustLocalize("kafka.create.cmd.longDescription"),
		Example: f.Localizer.MustLocalize("kafka.create.cmd.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			if opts.name != "" {
				validator := &kafkacmdutil.Validator{
					Localizer:  f.Localizer,
					Connection: f.Connection,
				}
				if err := validator.ValidateName(opts.name); err != nil {
					return err
				}
			}
			if !f.IOStreams.CanPrompt() && opts.name == "" {
				return f.Localizer.MustLocalizeError("kafka.create.argument.name.error.requiredWhenNonInteractive")
			} else if opts.name == "" {
				if opts.provider != "" || opts.region != "" {
					return f.Localizer.MustLocalizeError("kafka.create.argument.name.error.requiredWhenNonInteractive")
				}
				opts.interactive = true
			}
			validOutputFormats := flagutil.ValidOutputFormats
			if opts.outputFormat != "" && !flagutil.IsValidInput(opts.outputFormat, validOutputFormats...) {
				return flagutil.InvalidValueError("output", opts.outputFormat, validOutputFormats...)
			}
			return runCreate(opts)
		},
	}
	flags := kafkaFlagutil.NewFlagSet(cmd, f.Localizer)
	flags.StringVar(&opts.name, "name", "", f.Localizer.MustLocalize("kafka.create.flag.name.description"))
	flags.StringVar(&opts.provider, FlagProvider, "", f.Localizer.MustLocalize("kafka.create.flag.cloudProvider.description"))
	flags.StringVar(&opts.region, FlagRegion, "", f.Localizer.MustLocalize("kafka.create.flag.cloudRegion.description"))
	flags.StringVar(&opts.size, FlagSize, "", f.Localizer.MustLocalize("kafka.create.flag.size.description"))
	flags.AddOutput(&opts.outputFormat)
	flags.BoolVar(&opts.autoUse, "use", true, f.Localizer.MustLocalize("kafka.create.flag.autoUse.description"))
	flags.BoolVarP(&opts.wait, "wait", "w", false, f.Localizer.MustLocalize("kafka.create.flag.wait.description"))
	flags.BoolVarP(&opts.dryRun, "dry-run", "", false, f.Localizer.MustLocalize("kafka.create.flag.dryrun.description"))
	flags.AddBypassTermsCheck(&opts.bypassChecks)
	_ = cmd.RegisterFlagCompletionFunc(FlagProvider, func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
		return GetCloudProviderCompletionValues(f)
	})
	_ = cmd.RegisterFlagCompletionFunc(FlagRegion, func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
		return GetCloudProviderRegionCompletionValues(f, opts.provider)
	})
	_ = cmd.RegisterFlagCompletionFunc(FlagSize, func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
		return GetKafkaSizeCompletionValues(f, opts.provider, opts.region)
	})
	return cmd
}
func NewCreateCommand ( 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 opts . name != " " { validator := & kafkacmdutil . Validator { Localizer : f . Localizer , Connection : f . Connection , } if err := validator . ValidateName ( opts . name ) ; err != nil { return err } } if ! f . IOStreams . CanPrompt ( ) && opts . name == " " { return f . Localizer . MustLocalizeError ( " " ) } else if opts . name == " " { if opts . provider != " " || opts . region != " " { return f . Localizer . MustLocalizeError ( " " ) } opts . interactive = true } validOutputFormats := flagutil . ValidOutputFormats if opts . outputFormat != " " && ! flagutil . IsValidInput ( opts . outputFormat , validOutputFormats ... ) { return flagutil . InvalidValueError ( " " , opts . outputFormat , validOutputFormats ... ) } return runCreate ( opts ) } , } flags := kafkaFlagutil . NewFlagSet ( cmd , f . Localizer ) flags . StringVar ( & opts . name , " " , " " , f . Localizer . MustLocalize ( " " ) ) flags . StringVar ( & opts . provider , FlagProvider , " " , f . Localizer . MustLocalize ( " " ) ) flags . StringVar ( & opts . region , FlagRegion , " " , f . Localizer . MustLocalize ( " " ) ) flags . StringVar ( & opts . size , FlagSize , " " , f . Localizer . MustLocalize ( " " ) ) flags . AddOutput ( & opts . outputFormat ) flags . BoolVar ( & opts . autoUse , " " , true , f . Localizer . MustLocalize ( " " ) ) flags . BoolVarP ( & opts . wait , " " , " " , false , f . Localizer . MustLocalize ( " " ) ) flags . BoolVarP ( & opts . dryRun , " " , " " , false , f . Localizer . MustLocalize ( " " ) ) flags . AddBypassTermsCheck ( & opts . bypassChecks ) _ = cmd . RegisterFlagCompletionFunc ( FlagProvider , func ( cmd * cobra . Command , _ [ ] string , _ string ) ( [ ] string , cobra . ShellCompDirective ) { return GetCloudProviderCompletionValues ( f ) } ) _ = cmd . RegisterFlagCompletionFunc ( FlagRegion , func ( cmd * cobra . Command , _ [ ] string , _ string ) ( [ ] string , cobra . ShellCompDirective ) { return GetCloudProviderRegionCompletionValues ( f , opts . provider ) } ) _ = cmd . RegisterFlagCompletionFunc ( FlagSize , func ( cmd * cobra . Command , _ [ ] string , _ string ) ( [ ] string , cobra . ShellCompDirective ) { return GetKafkaSizeCompletionValues ( f , opts . provider , opts . region ) } ) return cmd }
NewCreateCommand creates a new command for creating kafkas.
NewCreateCommand creates a new command for creating kafkas .