Deduplicate openqa-cli options and help#6316
Conversation
54b818e to
5ad6505
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6316 +/- ##
=======================================
Coverage 99.11% 99.11%
=======================================
Files 399 399
Lines 40721 40771 +50
=======================================
+ Hits 40362 40412 +50
Misses 359 359 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5ad6505 to
66ab510
Compare
lib/OpenQA/CLI.pm
Outdated
| sub _print_options ($label, $options) { | ||
| my $help = "$label\n"; | ||
| my @rows; | ||
| my $max = 15; |
There was a problem hiding this comment.
what's the meaning of this magic number?
There was a problem hiding this comment.
I could set it to zero.
It's the width of the left column, determined by the maximum item length, and I just thought it would be nice to have a minimum width if there are only very short items.
There was a problem hiding this comment.
ok. how about a constant called accordingly?
There was a problem hiding this comment.
I found a better way. I just use Getopt::Long::Descriptive which provides a function to generate the usage table.
The format of the option spec is compatible between Getopt::Long, Getopt::Long::Descriptive and App::Spec.
c5a704a to
bdd9f0c
Compare
|
Not sure how to solve this error: Where should I put a file that the client needs to read? |
How about datadir/openqa/client |
I guess the easiest would be somewhere in lib/openQA as under |
This comment was marked as resolved.
This comment was marked as resolved.
4d22819 to
edaea44
Compare
|
The file will now be installed to |
Martchus
left a comment
There was a problem hiding this comment.
Looks good I guess. I only have a small nitpick on the use lines.
edaea44 to
dcffff3
Compare
dcffff3 to
47c3c7b
Compare
The file openqa-cli.yaml needs to be readable. See: os-autoinst/openQA#6316
The file openqa-cli.yaml needs to be readable. See: os-autoinst/openQA#6316
Use a spec file to deduplicate the options and help output for openqa-cli.
Advantages
Only one place, no duplicated information that can diverge over time
Currently the global options are repeated in several places:
And the options for the subcommands are also duplicated:
Some of the options were forgotten in the pod, e.g. archive does not list
--pretty,--quietand--verboseEasy shell completion
@b10n1k had the nice idea to add shell completion for openqa-cli (#6063).
However, manually written completion scripts have several disadvantages. Typos, and the content can diverge over time. Duplicated information again.
With the spec file we can get bas/zsh completion practically for free with appspec, including completion descriptions for bash.
We only have to regenerate it when an option gets added/changed, and a test can ensure that we don't forget regeneration.
So appspec would only be a dependency for us openQA authors.
(Note that this PR doesn't include completion yet)