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

chore(ux): improve error message when attaching without subject artifact #1430

Open qweeah opened 1 week ago

qweeah commented 1 week ago

What this PR does / why we need it: This PR improves error message when the oras attach is run with only one argument, which might be an invalid artifact subject reference or mistakenly used as a to-be-uploaded file path.

Before

> oras attach --artifact-type test/example $ARTIFACT ./layers 
Error: neither file nor annotation provided in the command
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]
To attach to an existing artifact, please provide files via argument or annotations via flag "--annotation". Run "oras attach -h" for more options and examples

After

> oras attach --artifact-type test/example $ARTIFACT ./layers 
Error: "./layers": no tag or digest specified
Usage: oras attach [flags] --artifact-type=<type> <name>{:<tag>|@<digest>} <file>[:<layer_media_type>] [...]
Have you specified an artifact reference to attach to? Please specify a reference in the form of "<name>:<tag>" or "<name>@<digest>". Run "oras attach -h" for more options and examples

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #1424, #1404

Please check the following list:

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.35%. Comparing base (ecb7878) to head (e3e5212).

:exclamation: Current head e3e5212 differs from pull request most recent head fe412f6

Please upload reports for the commit fe412f6 to get more accurate results.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1430 +/- ## ========================================== + Coverage 85.22% 85.35% +0.12% ========================================== Files 106 106 Lines 3798 3804 +6 ========================================== + Hits 3237 3247 +10 + Misses 336 333 -3 + Partials 225 224 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

wangxiaoxuan273 commented 1 week ago

LGTM but I'm not a maintainer