fix(commands): argument count limiters
Description
This is the first in a series of PR's I intend to be sending related to improving glab's shell completions.
This one does actually not do anything to shell completions, but just improves and fixes things related to positional argument count limits I came across while working on some positional completion improvements. I think this is large enough to be submitted as its own MR. Many files are touched, but the changes are small and should be uncontroversial.
There are a bunch of commits, each addressing a specific thing. List of commit messages is included below.
-
refactor(commands): use standard cobra.MinimumNArgs, remove cmdutils.MinimumArgs
-
fix(commands): ssh-key list argument count limit
-
fix(commands): release delete argument count limit
-
fix(commands): opentofu state delete/download argument count limits
-
fix(commands): gpg-key list argument count limit
-
fix(commands): deploy-key list argument count limit
-
fix(commands): cluster agent list argument count limit
-
fix(commands): add missing positional argument count limiters
-
refactor(commands): make more use of cobra.ArbitraryArgs
To serve as a marker for Args having been thought of rather than inadvertently omitted.
- refactor(commands): use cobra.ExactArgs(1) instead of cobra.RangeArgs(1,1)
For cleanliness and better error message.
- refactor(commands): use cobra.NoArgs instead of ExactArgs/MaximumNArgs(0)
For cleanliness.
Related Issues
Does not resolve, but relates to #8167
How has this been tested?
Tested a number of these commands by giving incorrect numbers of arguments. I did not test run every single one of the modified ones.