-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
coreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIa request to improve CLIgh-cacherelating to the gh cache commandrelating to the gh cache command
Description
Describe the feature or problem you’d like to solve
When using gh cache list --json <fields> in a repository without workflow caches, the command outputs a error message instead of JSON.
$ gh cache list --json id
No caches found in <repository name>This behavior breaks JSON parsing in automated scripts since they expect valid JSON output and they need extra error handling.
For consistent JSON output format, the output should be [].
Proposed solution
When the --json option is used, gh cache list should retuan an empty JSON array ([]) to indicate no caches exist.
$ gh cache list --json id
[]The text message should still be shown when running without the --json flag.
Additional context
gh version:gh version 2.60.1 (2024-10-25)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIa request to improve CLIgh-cacherelating to the gh cache commandrelating to the gh cache command