diff --git a/cmd/oras/root/manifest/fetch.go b/cmd/oras/root/manifest/fetch.go index b8ea03489..46b75d11a 100644 --- a/cmd/oras/root/manifest/fetch.go +++ b/cmd/oras/root/manifest/fetch.go @@ -104,7 +104,9 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar': cmd.Flags().StringSliceVarP(&opts.mediaTypes, "media-type", "", nil, "accepted media types") cmd.Flags().StringVarP(&opts.outputPath, "output", "o", "", "file `path` to write the fetched manifest to, use - for stdout") - cmd.Flags().StringVar(&opts.Template, "format", "", `Print output using the given Go template.`) + cmd.Flags().StringVar(&opts.Template, "format", "", `Format output using a custom template: +'json': Print manifest in prettified JSON format +'$TEMPLATE': Print output using the given Go template.`) option.ApplyFlags(&opts, cmd.Flags()) return oerrors.Command(cmd, &opts.Target) } diff --git a/test/e2e/suite/command/manifest.go b/test/e2e/suite/command/manifest.go index f7e52ad01..bf3579e64 100644 --- a/test/e2e/suite/command/manifest.go +++ b/test/e2e/suite/command/manifest.go @@ -97,6 +97,15 @@ var _ = Describe("ORAS beginners:", func() { It("should fail with suggestion if no tag or digest is provided", func() { ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, "")).ExpectFailure().MatchErrKeyWords("Error:", "no tag or digest specified", "oras manifest fetch [flags] {:|@}", "Please specify a reference").Exec() }) + + It("should fail if stdout is used inpropriately", func() { + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--output", "-", "--format", "test"). + ExpectFailure().Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--descriptor", "--format", "test"). + ExpectFailure().Exec() + ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--output", "-", "--descriptor"). + ExpectFailure().Exec() + }) }) When("running `manifest delete`", func() {