From cbf58e6252011ad68e066179a79d935fe45bbffa Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 7 Nov 2022 14:12:05 +0800 Subject: [PATCH] feat!: alias remove to delete Signed-off-by: Billy Zha --- cmd/oras/blob/delete.go | 11 ++++++----- cmd/oras/internal/option/confirmation.go | 2 +- cmd/oras/manifest/delete.go | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/oras/blob/delete.go b/cmd/oras/blob/delete.go index e67f0ae69..4f0f64118 100644 --- a/cmd/oras/blob/delete.go +++ b/cmd/oras/blob/delete.go @@ -38,8 +38,9 @@ type deleteBlobOptions struct { func deleteCmd() *cobra.Command { var opts deleteBlobOptions cmd := &cobra.Command{ - Use: "delete [flags] @", - Short: "[Preview] Delete a blob from a remote registry", + Use: "delete [flags] @", + Aliases: []string{"remove", "rm"}, + Short: "[Preview] Delete a blob from a remote registry", Long: `[Preview] Delete a blob from a remote registry ** This command is in preview and under development. ** @@ -48,15 +49,15 @@ Example - Delete a blob: oras blob delete localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 Example - Delete a blob without prompting confirmation: - oras blob delete --yes localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 + oras blob delete --force localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 Example - Delete a blob and print its descriptor: - oras blob delete --descriptor --yes localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 + oras blob delete --descriptor --force localhost:5000/hello@sha256:9a201d228ebd966211f7d1131be19f152be428bd373a92071c71d8deaf83b3e5 `, Args: cobra.ExactArgs(1), PreRunE: func(cmd *cobra.Command, args []string) error { if opts.OutputDescriptor && !opts.Confirmed { - return errors.New("must apply --yes to confirm the deletion if the descriptor is outputted") + return errors.New("must apply --force to confirm the deletion if the descriptor is outputted") } return opts.ReadPassword() }, diff --git a/cmd/oras/internal/option/confirmation.go b/cmd/oras/internal/option/confirmation.go index 0dae7e066..b18a5d9b1 100644 --- a/cmd/oras/internal/option/confirmation.go +++ b/cmd/oras/internal/option/confirmation.go @@ -31,7 +31,7 @@ type Confirmation struct { // ApplyFlags applies flags to a command flag set. func (opts *Confirmation) ApplyFlags(fs *pflag.FlagSet) { - fs.BoolVarP(&opts.Confirmed, "yes", "y", false, "do not prompt for confirmation") + fs.BoolVarP(&opts.Confirmed, "force", "f", false, "do not prompt for confirmation") } // AskForConfirmation prints a propmt to ask for confirmation before doing an diff --git a/cmd/oras/manifest/delete.go b/cmd/oras/manifest/delete.go index fed2bf775..568eefd91 100644 --- a/cmd/oras/manifest/delete.go +++ b/cmd/oras/manifest/delete.go @@ -39,8 +39,9 @@ type deleteOptions struct { func deleteCmd() *cobra.Command { var opts deleteOptions cmd := &cobra.Command{ - Use: "delete [flags] {:|@}", - Short: "[Preview] Delete a manifest from remote registry", + Use: "delete [flags] {:|@}", + Aliases: []string{"remove", "rm"}, + Short: "[Preview] Delete a manifest from remote registry", Long: `[Preview] Delete a manifest from remote registry ** This command is in preview and under development. ** @@ -49,7 +50,7 @@ Example - Delete a manifest tagged with 'latest' from repository 'localhost:5000 oras manifest delete localhost:5000/hello:latest Example - Delete a manifest without prompting confirmation: - oras manifest delete --yes localhost:5000/hello:latest + oras manifest delete --force localhost:5000/hello:latest Example - Delete a manifest and print its descriptor: oras manifest delete --descriptor localhost:5000/hello:latest @@ -60,7 +61,7 @@ Example - Delete a manifest by digest 'sha256:99e4703fbf30916f549cd6bfa9cdbab614 Args: cobra.ExactArgs(1), PreRunE: func(cmd *cobra.Command, args []string) error { if opts.OutputDescriptor && !opts.Confirmed { - return errors.New("must apply --yes to confirm the deletion if the descriptor is outputted") + return errors.New("must apply --force to confirm the deletion if the descriptor is outputted") } return opts.ReadPassword() },