// NewDescribeCommand describes a service instance, either by passing an `--id flag`
// or by using the service instance set in the current context, if any
NewDescribeCommand describes a service instance, either by passing an `--id flag`
or by using the service instance set in the current context, if any
// NewDescribeCommand describes a service instance either by passing an ` -- id flag ` // or by using the service instance set in the current context if any
func NewDescribeCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		Connection:     f.Connection,
		IO:             f.IOStreams,
		localizer:      f.Localizer,
		Context:        f.Context,
		logger:         f.Logger,
		ServiceContext: f.ServiceContext,
	}
	cmd := &cobra.Command{
		Use:     "describe",
		Short:   f.Localizer.MustLocalize("registry.cmd.describe.shortDescription"),
		Long:    f.Localizer.MustLocalize("registry.cmd.describe.longDescription"),
		Example: f.Localizer.MustLocalize("registry.cmd.describe.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			validOutputFormats := flagutil.ValidOutputFormats
			if opts.outputFormat != "" && !flagutil.IsValidInput(opts.outputFormat, validOutputFormats...) {
				return flagutil.InvalidValueError("output", opts.outputFormat, validOutputFormats...)
			}
			if opts.name != "" && opts.id != "" {
				return opts.localizer.MustLocalizeError("service.error.idAndNameCannotBeUsed")
			}
			if opts.id != "" || opts.name != "" {
				return runDescribe(opts)
			}
			registryInstance, err := contextutil.GetCurrentRegistryInstance(f)
			if err != nil {
				return err
			}
			opts.id = registryInstance.GetId()
			return runDescribe(opts)
		},
	}
	cmd.Flags().StringVar(&opts.name, "name", "", opts.localizer.MustLocalize("registry.cmd.describe.flag.name.description"))
	cmd.Flags().StringVarP(&opts.outputFormat, "output", "o", "json", opts.localizer.MustLocalize("registry.cmd.flag.output.description"))
	cmd.Flags().StringVar(&opts.id, "id", "", opts.localizer.MustLocalize("registry.describe.flag.id"))
	flagutil.EnableOutputFlagCompletion(cmd)
	return cmd
}
func NewDescribeCommand ( f * factory . Factory ) * cobra . Command { opts := & options { Connection : f . Connection , IO : f . IOStreams , localizer : f . Localizer , Context : f . Context , logger : f . Logger , 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 { validOutputFormats := flagutil . ValidOutputFormats if opts . outputFormat != " " && ! flagutil . IsValidInput ( opts . outputFormat , validOutputFormats ... ) { return flagutil . InvalidValueError ( " " , opts . outputFormat , validOutputFormats ... ) } if opts . name != " " && opts . id != " " { return opts . localizer . MustLocalizeError ( " " ) } if opts . id != " " || opts . name != " " { return runDescribe ( opts ) } registryInstance , err := contextutil . GetCurrentRegistryInstance ( f ) if err != nil { return err } opts . id = registryInstance . GetId ( ) return runDescribe ( opts ) } , } cmd . Flags ( ) . StringVar ( & opts . name , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVarP ( & opts . outputFormat , " " , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVar ( & opts . id , " " , " " , opts . localizer . MustLocalize ( " " ) ) flagutil . EnableOutputFlagCompletion ( cmd ) return cmd }
NewDescribeCommand describes a service instance, either by passing an `--id flag`
or by using the service instance set in the current context, if any
NewDescribeCommand describes a service instance either by passing an ` -- id flag ` or by using the service instance set in the current context if any