oras icon indicating copy to clipboard operation
oras copied to clipboard

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

Open qweeah opened this issue 1 year ago • 2 comments

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:

  • [x] Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • [ ] Does this change require a documentation update?
  • [ ] Does this introduce breaking changes that would require an announcement or bumping the major version?
  • [ ] Do all new files have an appropriate license header?

qweeah avatar Jun 24 '24 00:06 qweeah

Codecov Report

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

Project coverage is 85.41%. Comparing base (e7ffb65) to head (e1163c7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1430      +/-   ##
==========================================
+ Coverage   85.38%   85.41%   +0.02%     
==========================================
  Files         108      108              
  Lines        3818     3825       +7     
==========================================
+ Hits         3260     3267       +7     
- Misses        333      334       +1     
+ Partials      225      224       -1     

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

codecov[bot] avatar Jun 24 '24 00:06 codecov[bot]

LGTM but I'm not a maintainer

wangxiaoxuan273 avatar Jun 24 '24 02:06 wangxiaoxuan273