// NewGenerateCommand creates configuration files for service context
NewGenerateCommand creates configuration files for service context
// NewGenerateCommand creates configuration files for service context
func NewGenerateCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		Connection:     f.Connection,
		Config:         f.Config,
		IO:             f.IOStreams,
		Logger:         f.Logger,
		localizer:      f.Localizer,
		ServiceContext: f.ServiceContext,
	}
	cmd := &cobra.Command{
		Use:     "generate-config",
		Short:   f.Localizer.MustLocalize("generate.cmd.shortDescription"),
		Long:    f.Localizer.MustLocalize("generate.cmd.longDescription"),
		Example: f.Localizer.MustLocalize("generate.cmd.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			validType := flagutil.IsValidInput(opts.configType, configurationTypes...)
			if !validType {
				return flagutil.InvalidValueError("type", opts.configType, configurationTypes...)
			}
			return runGenerate(opts)
		},
	}
	flags := contextcmdutil.NewFlagSet(cmd, f)
	flags.AddContextName(&opts.name)
	flags.StringVar(&opts.configType, "type", "", opts.localizer.MustLocalize("generate.flag.type"))
	cmd.Flags().StringVar(&opts.fileName, "output-file", "", opts.localizer.MustLocalize("generate.common.flag.fileLocation.description"))
	_ = cmd.MarkFlagRequired("type")
	flagutil.EnableStaticFlagCompletion(cmd, "type", configurationTypes)
	return cmd
}
func NewGenerateCommand ( f * factory . Factory ) * cobra . Command { opts := & options { Connection : f . Connection , Config : f . Config , 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 { validType := flagutil . IsValidInput ( opts . configType , configurationTypes ... ) if ! validType { return flagutil . InvalidValueError ( " " , opts . configType , configurationTypes ... ) } return runGenerate ( opts ) } , } flags := contextcmdutil . NewFlagSet ( cmd , f ) flags . AddContextName ( & opts . name ) flags . StringVar ( & opts . configType , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVar ( & opts . fileName , " " , " " , opts . localizer . MustLocalize ( " " ) ) _ = cmd . MarkFlagRequired ( " " ) flagutil . EnableStaticFlagCompletion ( cmd , " " , configurationTypes ) return cmd }
NewGenerateCommand creates configuration files for service context
NewGenerateCommand creates configuration files for service context
// check that a valid type is provided