diff --git a/cmd/oras/root/manifest/fetch.go b/cmd/oras/root/manifest/fetch.go index abe211c8f..9b60cb991 100644 --- a/cmd/oras/root/manifest/fetch.go +++ b/cmd/oras/root/manifest/fetch.go @@ -74,11 +74,15 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar': switch { case opts.outputPath == "-" && opts.Template != "": return fmt.Errorf("`--output -` cannot be used with `--format %s` at the same time", opts.Template) - case opts.OutputDescriptor && opts.Template != "": - return fmt.Errorf("`--descriptor` cannot be used with `--format %s` at the same time", opts.Template) case opts.OutputDescriptor && opts.outputPath == "-": return fmt.Errorf("`--descriptor` cannot be used with `--output -` at the same time") } + if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "pretty"); err != nil { + return err + } + if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "descriptor"); err != nil { + return err + } opts.RawReference = args[0] return option.Parse(cmd, &opts) }, diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index 58adfa7c3..fafe683a8 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -112,6 +112,8 @@ var _ = Describe("ORAS beginners:", func() { ExpectFailure().Exec() ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--output", "-", "--descriptor"). ExpectFailure().Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--format", "test", "--pretty"). + ExpectFailure().Exec() }) })