// NewListCommand creates a new command for listing service registries.
NewListCommand creates a new command for listing service registries.
// NewListCommand creates a new command for listing service registries .
func NewListCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		Connection:     f.Connection,
		Logger:         f.Logger,
		IO:             f.IOStreams,
		localizer:      f.Localizer,
		Context:        f.Context,
		ServiceContext: f.ServiceContext,
	}
	cmd := &cobra.Command{
		Use:     "list",
		Short:   f.Localizer.MustLocalize("registry.cmd.list.shortDescription"),
		Long:    f.Localizer.MustLocalize("registry.cmd.list.longDescription"),
		Example: f.Localizer.MustLocalize("registry.cmd.list.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			if opts.outputFormat != "" && !flagutil.IsValidInput(opts.outputFormat, flagutil.ValidOutputFormats...) {
				return flagutil.InvalidValueError("output", opts.outputFormat, flagutil.ValidOutputFormats...)
			}
			if opts.page < 1 {
				return opts.localizer.MustLocalizeError("common.validation.page.error.invalid.minValue", localize.NewEntry("Page", opts.page))
			}
			if opts.limit < 1 {
				return opts.localizer.MustLocalizeError("common.validation.limit.error.invalid.minValue", localize.NewEntry("Limit", opts.limit))
			}
			return runList(opts)
		},
	}
	cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "", opts.localizer.MustLocalize("registry.cmd.flag.output.description"))
	cmd.Flags().Int32VarP(&opts.page, "page", "", cmdutil.ConvertPageValueToInt32(build.DefaultPageNumber), opts.localizer.MustLocalize("registry.list.flag.page"))
	cmd.Flags().Int32VarP(&opts.limit, "limit", "", 100, opts.localizer.MustLocalize("registry.list.flag.limit"))
	flagutil.EnableOutputFlagCompletion(cmd)
	return cmd
}
func NewListCommand ( f * factory . Factory ) * cobra . Command { opts := & options { Connection : f . Connection , Logger : f . Logger , IO : f . IOStreams , localizer : f . Localizer , Context : f . Context , 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 . outputFormat != " " && ! flagutil . IsValidInput ( opts . outputFormat , flagutil . ValidOutputFormats ... ) { return flagutil . InvalidValueError ( " " , opts . outputFormat , flagutil . ValidOutputFormats ... ) } if opts . page < 1 { return opts . localizer . MustLocalizeError ( " " , localize . NewEntry ( " " , opts . page ) ) } if opts . limit < 1 { return opts . localizer . MustLocalizeError ( " " , localize . NewEntry ( " " , opts . limit ) ) } return runList ( opts ) } , } cmd . Flags ( ) . StringVarP ( & opts . outputFormat , " " , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . Int32VarP ( & opts . page , " " , " " , cmdutil . ConvertPageValueToInt32 ( build . DefaultPageNumber ) , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . Int32VarP ( & opts . limit , " " , " " , 100 , opts . localizer . MustLocalize ( " " ) ) flagutil . EnableOutputFlagCompletion ( cmd ) return cmd }
NewListCommand creates a new command for listing service registries.
NewListCommand creates a new command for listing service registries .