// NewSetMetadataCommand creates a new command for updating metadata for registry artifacts.
NewSetMetadataCommand creates a new command for updating metadata for registry artifacts.
// NewSetMetadataCommand creates a new command for updating metadata for registry artifacts .
func NewSetStateCommand(f *factory.Factory) *cobra.Command {
	opts := &options{
		Connection:     f.Connection,
		IO:             f.IOStreams,
		localizer:      f.Localizer,
		Logger:         f.Logger,
		context:        f.Context,
		ServiceContext: f.ServiceContext,
	}
	cmd := &cobra.Command{
		Use:     "state-set",
		Short:   f.Localizer.MustLocalize("artifact.cmd.stateset.description.short"),
		Long:    f.Localizer.MustLocalize("artifact.cmd.stateset.description.long"),
		Example: f.Localizer.MustLocalize("artifact.cmd.stateset.example"),
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			if opts.artifact == "" {
				return f.Localizer.MustLocalizeError("artifact.common.message.artifactIdRequired")
			}
			if _, err := registryinstanceclient.NewArtifactStateFromValue(opts.state); err != nil {
				return opts.localizer.MustLocalizeError("artifact.cmd.state.error.invalidArtifactState", localize.NewEntry("AllowedTypes", util.GetAllowedArtifactStateEnumValuesAsString()))
			}
			if opts.registryID != "" {
				return runSet(opts)
			}
			registryInstance, err := contextutil.GetCurrentRegistryInstance(f)
			if err != nil {
				return err
			}
			opts.registryID = registryInstance.GetId()
			return runSet(opts)
		},
	}
	cmd.Flags().StringVar(&opts.artifact, "artifact-id", "", opts.localizer.MustLocalize("artifact.common.id"))
	cmd.Flags().StringVarP(&opts.group, "group", "g", registrycmdutil.DefaultArtifactGroup, opts.localizer.MustLocalize("artifact.common.group"))
	cmd.Flags().StringVar(&opts.registryID, "instance-id", "", opts.localizer.MustLocalize("registry.common.flag.instance.id"))
	cmd.Flags().StringVar(&opts.state, "state", "", opts.localizer.MustLocalize("artifact.flag.state.description"))
	_ = cmd.RegisterFlagCompletionFunc("state", func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
		return util.AllowedArtifactStateEnumValues, cobra.ShellCompDirectiveNoSpace
	})
	return cmd
}
func NewSetStateCommand ( f * factory . Factory ) * cobra . Command { opts := & options { Connection : f . Connection , IO : f . IOStreams , localizer : f . Localizer , Logger : f . Logger , 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 . artifact == " " { return f . Localizer . MustLocalizeError ( " " ) } if _ , err := registryinstanceclient . NewArtifactStateFromValue ( opts . state ) ; err != nil { return opts . localizer . MustLocalizeError ( " " , localize . NewEntry ( " " , util . GetAllowedArtifactStateEnumValuesAsString ( ) ) ) } if opts . registryID != " " { return runSet ( opts ) } registryInstance , err := contextutil . GetCurrentRegistryInstance ( f ) if err != nil { return err } opts . registryID = registryInstance . GetId ( ) return runSet ( opts ) } , } cmd . Flags ( ) . StringVar ( & opts . artifact , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVarP ( & opts . group , " " , " " , registrycmdutil . DefaultArtifactGroup , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVar ( & opts . registryID , " " , " " , opts . localizer . MustLocalize ( " " ) ) cmd . Flags ( ) . StringVar ( & opts . state , " " , " " , opts . localizer . MustLocalize ( " " ) ) _ = cmd . RegisterFlagCompletionFunc ( " " , func ( cmd * cobra . Command , _ [ ] string , _ string ) ( [ ] string , cobra . ShellCompDirective ) { return util . AllowedArtifactStateEnumValues , cobra . ShellCompDirectiveNoSpace } ) return cmd }
NewSetMetadataCommand creates a new command for updating metadata for registry artifacts.
NewSetMetadataCommand creates a new command for updating metadata for registry artifacts .