Skip to content

fix(cli): pluralize "argument" in argument-count errors - #2161

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
akshita317:fix/argument-count-pluralization
Sep 8, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
akshita317:fix/argument-count-pluralization

Conversation

@akshita317

Copy link
Copy Markdown
Contributor

Problem

Exactly and AtLeast hardcode the singular noun, so any command requiring more than one argument reports a count that disagrees with it:

$ oras cp foo
Error: "oras cp" requires exactly 2 argument but got 1
Usage: oras cp [flags] <from>{:<tag>|@<digest>} <to>[:<tag>[,<tag>][...]]
Please specify exactly 2 argument as the source and destination for copying. Run "oras cp -h" for more options and examples

The text appears twice per failure, since errors.CheckArgs reuses the same string in both the error and the recommendation. It affects oras cp and oras blob push, the commands taking exactly 2 arguments.

Why this wording

docs/proposals/error-handling-guideline.md already specifies the plural form as the intended output:

$ oras cp
Error: "oras copy" requires exactly 2 arguments but received 0.

So this is the implementation catching up with the documented guideline, not a new style choice.

After

$ oras cp foo
Error: "oras cp" requires exactly 2 arguments but got 1
Please specify exactly 2 arguments as the source and destination for copying. ...

$ oras login
Error: "oras login" requires exactly 1 argument but got 0     # singular preserved

$ oras attach
Error: "oras attach" requires at least 1 argument but got 0   # singular preserved

A count of 0 reads "exactly 0 arguments", which matches ordinary English usage.

Tests

This package had no test file (0% statement coverage). Added table-driven tests covering both checkers across counts 0–2, asserting the boolean result and the exact message. The package is now at 100% statement coverage.

$ go test ./cmd/oras/internal/argument/ -cover
ok      oras.land/oras/cmd/oras/internal/argument       coverage: 100.0% of statements

Nothing in the repo asserts on the old string — no e2e suite or unit test matches requires exactly / at least ... argument — so no other tests needed updating. go test ./..., gofmt and go vet are clean.

Exactly and AtLeast hardcode the singular noun, so every command that
requires more than one argument reports a count that does not agree with
it:

    $ oras cp foo
    Error: "oras cp" requires exactly 2 argument but got 1
    Please specify exactly 2 argument as the source and destination for
    copying. Run "oras cp -h" for more options and examples

The text appears twice per failure, since errors.CheckArgs uses the same
string in both the error and the recommendation. It reaches users of
`oras cp` and `oras blob push`, which are the commands taking exactly 2
arguments.

docs/proposals/error-handling-guideline.md already specifies the plural
form as the intended wording:

    Error: "oras copy" requires exactly 2 arguments but received 0.

so this brings the implementation in line with the documented guideline.
Counts of 1 keep the singular, and 0 reads "exactly 0 arguments".

Also add tests for this package, which had no test file. They cover both
checkers over counts 0 through 2, asserting the boolean result and the
exact message, and take the package from 0% to 100% statement coverage.

Signed-off-by: Akshita <[email protected]>
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.67%. Comparing base (4728be6) to head (3e88593).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2161   +/-   ##
=======================================
  Coverage   87.66%   87.67%           
=======================================
  Files         139      139           
  Lines        5685     5689    +4     
=======================================
+ Hits         4984     4988    +4     
  Misses        418      418           
  Partials      283      283           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@TerryHowe
TerryHowe merged commit 898a195 into oras-project:main Sep 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants