oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.33k stars 160 forks source link

`oras discover` shows wrong error message #1348

Closed qweeah closed 2 months ago

qweeah commented 2 months ago

What happened in your environment?

If --output and --format are used at the same time, flag confliction error is output

> oras discover localhost:7000/demo:eol --format "{{.manifests}}" --output json
[DEPRECATED] --output is deprecated, try `--format json` instead
Error: if any flags in the group [output format] are set none of the others can be; [format output] were all set

But if the --output flag is used before --format, wrong error output is shown:

> oras discover localhost:7000/demo:eol --output json --format "{{.manifests}}"
Error: output type can only be tree, table or json

What did you expect to happen?

Should always show error message that both flags cannot be used at the same time

How can we reproduce it?

Run below command

oras discover localhost:7000/demo:eol --output json --format "{{.manifests}}"

What is the version of your ORAS CLI?

Main branch build from https://github.com/oras-project/oras/commit/fa65f61c86fa75b23b8f2afffe1ba77a5fbf44b7

What is your OS environment?

Ubuntu 20.04

Are you willing to submit PRs to fix it?

qweeah commented 2 months ago

@wangxiaoxuan273 Can you also help fix this since the fix for #1340 can be applied to fix this issue?