Parse -v parameter on any position
- Dominant language
- Go
- Stars
- 50
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Option `-v` is currently working only when specified directly after `g2a` command. Since usually `-v` parameter is added when users try to run command _again_ in order to debug why it failed, it's really convieniet to add it on the very end of the line. The problem is, when `-v` is specified after name of subcommand, we cannot reliably parse it and remove it from parameters passed down to sub-command. To illustrate the issue, take a look for these examples:
* `g2a cmd -v` – is `-v` verbosity parameter or some other parameter used by `cmd` command?
* `g2a cmd -vv` – is `-vvv` a `-v` parameter specified 2 times, or `-v` parameter with `v` value?
* `g2a cmd -xv` – is `-xv` two parameters, or single `-x` parameter with `v` value?
* `g2a cmd --param -v` – is `-v` a parameter or a value of `--param` parameter?
It's impossible to mitigate all these issues without knowing exact structure of the sub-command's parameters, but we can try to reduce their impact by applying following rules:
* If `-v` is specified after command name, pass it with the rest of parameters to this command (do not intercept it).
* Parse only standalone occurences like `-vv` and `--verbose`, paramenters like `-xv` have to be ignored.
* Behaviour of other global parameters (like `--log-level`) shouldn't be changed (they should be parsed only if specified before command name).
Since it will cause errors on commands wich doesn't accept unknown parameters, this change must apply only to commands using API newer than "g2a-cli/v1beta1".
Contributor guide
Assessment
This issue has not been assessed yet.