-
Notifications
You must be signed in to change notification settings - Fork 214
Deduplicate openqa-cli options and help #6316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.04% 99.04%
=======================================
Files 398 398
Lines 40045 40097 +52
=======================================
+ Hits 39663 39715 +52
Misses 382 382 ☔ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of this magic number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. how about a constant called accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
84d82e2
to
c5a704a
Compare
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 |
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
,--quiet
and--verbose
Easy 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)