feat(app): show the usage line on argument errors and allow -L up to 1000

Positional argument errors name what is wrong from the command's usage, then
print the usage line and where to find help:

  missing issue number
  Usage: tea issue view <number> [flags]
  Run 'tea issue view --help' for more information.

instead of "accepts 1 arg(s), received 0". Resource numbers accept #N.

--limit gains the gh shorthand -L and accepts up to 1000 results; the list
services already page through the server's smaller pages to fill a window.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-11 22:48:49 +02:00
1 parent 9b1d3a61e6
commit 2ef6090734
3 files changed
+167 -12

No files matched your search

+7 -7
View File
@@ -67,7 +67,7 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"issue", "edit", "1", "invalid", "--title", "Updated"}, "invalid resource number \"invalid\""},
{[]string{"issue", "edit", "1", "2", "--editor"}, "--editor requires one issue"},
{[]string{"issue", "edit", "1", "01", "--title", "Updated", "--no-input"}, "resource 1 is selected more than once"},
{[]string{"issue", "list", "--limit", "0"}, `"--limit" flag: must be 1..100`},
{[]string{"issue", "list", "--limit", "0"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"issue", "list", "--page", "0"}, `"--page" flag: must be a positive integer`},
{[]string{"issue", "list", "--label", "bug, "}, "label names cannot be empty"},
{[]string{"label", "create", "--name", "bug", "--color", "wrong"}, "--color requires six hexadecimal digits"},
@@ -83,11 +83,11 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"milestone", "edit", "9", "--title", " \t "}, "milestone title cannot be empty"},
{[]string{"milestone", "issue", "add", "7", "1", "01", "--no-input"}, "resource 1 is selected more than once"},
{[]string{"milestone", "issue", "remove", "7", "1", "1", "--no-input"}, "resource 1 is selected more than once"},
{[]string{"milestone", "list", "--limit", "101"}, `"--limit" flag: must be 1..100`},
{[]string{"milestone", "list", "--limit", "1001"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"milestone", "list", "--state", "merged"}, "--state must be open, closed, or all"},
{[]string{"notification", "list", "--status", "invalid"}, "--status must contain unread, read, or pinned"},
{[]string{"notification", "list", "--type", "invalid"}, "--type must contain issue, pull, commit, or repository"},
{[]string{"notification", "list", "--limit", "many"}, `"--limit" flag: must be 1..100`},
{[]string{"notification", "list", "--limit", "many"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"notification", "list", "--mine", "-R", "alice/project"}, "--mine and --repo are mutually exclusive"},
{[]string{"notification", "list", "--since="}, "invalid --since: use a date, RFC3339 timestamp, or duration such as 24h"},
{[]string{"notification", "list", "--since=1h", "--before=2h"}, "--since must not be later than --before"},
@@ -102,7 +102,7 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"org", "create", "team", "--visibility", "unknown"}, "--visibility must be public, limited, or private"},
{[]string{"org", "edit", "team"}, "supply organization fields to edit"},
{[]string{"org", "list", "--all", "--username", "alice"}, "--all and --username are mutually exclusive"},
{[]string{"org", "member", "list", "team", "--limit", "0"}, `"--limit" flag: must be 1..100`},
{[]string{"org", "member", "list", "team", "--limit", "0"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"pr", "attachment", "download", "1", "1"}, "supply --output-file, or --output-file - for stdout"},
{[]string{"pr", "attachment", "download", "1", "1", "--json"}, "attachment downloads are binary"},
{[]string{"pr", "attachment", "download", "1", "1", "--output-file", "-", "--json=id"}, "attachment downloads are binary"},
@@ -131,7 +131,7 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"pr", "list", "--sort", "unknown"}, "--sort must be oldest, recentupdate, recentclose, leastupdate, mostcomment, leastcomment, or priority"},
{[]string{"pr", "list", "--milestone", "-1"}, "--milestone must be a nonnegative ID"},
{[]string{"pr", "list", "--state", "unknown"}, "--state must be open, closed, or all"},
{[]string{"pr", "list", "--limit", "0"}, `"--limit" flag: must be 1..100`},
{[]string{"pr", "list", "--limit", "0"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"pr", "review", "1", "--no-input"}, "missing required input: supply --body"},
{[]string{"pr", "review", "1", "--body="}, "review body cannot be empty without inline comments"},
{[]string{"pr", "review", "1", "--event=unknown"}, "--event must be APPROVED, REQUEST_CHANGES, COMMENT, or PENDING"},
@@ -167,7 +167,7 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"repo", "edit", "--default-branch="}, "default branch cannot be empty"},
{[]string{"repo", "archive", "alice/project", "-R", "alice/other", "--yes"}, "supply the repository as an argument or --repo, not both"},
{[]string{"repo", "view", "alice/project", "--repo", "alice/other"}, "supply the repository as an argument or --repo, not both"},
{[]string{"repo", "view", "alice/project", "alice/other"}, "accepts at most 1 arg(s)"},
{[]string{"repo", "view", "alice/project", "alice/other"}, "too many arguments\nUsage: tea repo view [repository] [flags]"},
{[]string{"repo", "list", "--owner", "account", "--starred"}, "--owner, --starred, and --watched select mutually exclusive collections"},
{[]string{"repo", "list", "--starred", "--watched"}, "--owner, --starred, and --watched select mutually exclusive collections"},
{[]string{"repo", "list", "--type", "invalid"}, "--type must be fork, source, or mirror"},
@@ -189,7 +189,7 @@ func TestUsageErrorsPrecedeRequests(t *testing.T) {
{[]string{"run", "list", "--since=-1h"}, "invalid --since: relative duration cannot be negative"},
{[]string{"run", "list", "--until="}, "invalid --until: use a date, RFC3339 timestamp, or duration such as 24h"},
{[]string{"run", "list", "--since=1h", "--until=2h"}, "--since must not be later than --until"},
{[]string{"run", "list", "--limit", "0"}, `"--limit" flag: must be 1..100`},
{[]string{"run", "list", "--limit", "0"}, `"-L, --limit" flag: must be 1..1000`},
{[]string{"search", "issue", "query", "--state", "invalid"}, "--state must be open, closed, or all"},
{[]string{"search", "issue", "query", "--author", "alice", "--authored"}, "--author and --authored are mutually exclusive"},
{[]string{"search", "issue", "--label", ","}, "label names cannot be empty"},