Skip to content

Commit

Permalink
feat!: alias remove to delete
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Nov 7, 2022
1 parent 7c2b7a1 commit cbf58e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions cmd/oras/blob/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ type deleteBlobOptions struct {
func deleteCmd() *cobra.Command {
var opts deleteBlobOptions
cmd := &cobra.Command{
Use: "delete [flags] <name>@<digest>",
Short: "[Preview] Delete a blob from a remote registry",
Use: "delete [flags] <name>@<digest>",
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. **
Expand All @@ -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()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/internal/option/confirmation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions cmd/oras/manifest/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ type deleteOptions struct {
func deleteCmd() *cobra.Command {
var opts deleteOptions
cmd := &cobra.Command{
Use: "delete [flags] <name>{:<tag>|@<digest>}",
Short: "[Preview] Delete a manifest from remote registry",
Use: "delete [flags] <name>{:<tag>|@<digest>}",
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. **
Expand All @@ -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
Expand All @@ -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()
},
Expand Down

0 comments on commit cbf58e6

Please sign in to comment.