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
Support optional arg in -L (--color) short option #5890
Conversation
Hm, I don't approve this. I use |
Understood, I went for this approach bc A) we are already inconsistent, so some tools don't support -L. Do you think we should leave that be or add -L to those tools? B) I noticed Personally, I dislike the inconsistency more than the documentation issue. |
We should leave it off IMO if it hasn't had a use case. The short option is useful for commands that might be piped to
Yes, but if we're looking for prior examples, My preference would be to not remove existing options people may be using. I'm not so sure the short option must be added to commands where it is currently missing, but if it does bother you then that would be fine with me. Mainly I was thinking we just update docs to say |
Looks like dmesg uses getopt (if I have the right dmesg): from getopt(3):
|
Hm, in optparse we only do the two colons when a flag exists. Need to look at this again: if (o->has_arg == 1)
colons = ":";
else if (o->has_arg == 2 && o->flags & OPTPARSE_OPT_SHORTOPT_OPTIONAL_ARG)
colons = "::"; |
Yeah, I noticed last night but didn't look into it too much bc A) the approach I was going to take and B) dunno if we should rely on a GNU extension for optional short options? Can look at later as well. |
We have vendored gnu I wonder if "fixing" this will break usage like |
@grondo so someting like
similar with |
No, I meant it works in the Linux It works with
So I'm not 100% sure it is an improvement, though |
I had to remind myself why that flag exists:
|
This feels better IMO. There's a clear error message that makes sense with the |
Yeah, this would be fine with me. Some existing use cases would fail, but as long as Note that users may still get confused that |
d2c8be4
to
5db6f9a
Compare
re-pushed basically adding OPTPARSE_OPT_SHORTOPT_OPTIONAL_ARG in appropriate locations to get Updated a few tests to add
I did not make |
5db6f9a
to
a63cec5
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #5890 +/- ##
==========================================
- Coverage 83.31% 83.30% -0.01%
==========================================
Files 514 514
Lines 82809 82809
==========================================
- Hits 68990 68987 -3
- Misses 13819 13822 +3
|
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.
LGTM. Probably should reorder commits as suggested below, though.
@@ -136,7 +136,7 @@ nul_ctrl_d() { | |||
} | |||
test_expect_success 'pty: NUL (Ctrl-SPACE) character not dropped' ' | |||
nul_ctrl_d | flux run -vvv -o pty.interactive -o pty.capture cat -v && | |||
flux job eventlog -HLp output $(flux job last) && | |||
flux job eventlog -HLp output $(flux job last) | grep \\^@ | |||
flux job eventlog -HL -p output $(flux job last) && |
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.
This commit should probably go before 90f0d30 so the test isn't broken in between (and note in the commit message that -L
will be fixed to take an optional arg so this usage will break)
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.
oh yeah! i fixed that last as it was uncovered.
33ad653
to
82bfc7a
Compare
thanks re-ordered commits and tweaked that commit message. setting MWP |
Problem: In the near future the -L short option for --color can take an optional parameter. The usage in a test: flux job eventlog -HLp output $(flux job last) will break as a result since the -L option now believes "p" is the argument to -L. Update the usage to flux job eventlog -HL -p output $(flux job last) so it is clear -L is not being given an argument.
Problem: In several tools, the --color option takes an optional argument. However, the optional argument does not work with the short -L option. Add the OPTPARSE_OPT_SHORTOPT_OPTIONAL_ARG flag when parsing the --color option so that the -L option can take the optional argument correctly. Fixes flux-framework#5828
Problem: In several tests the --color option is tested but either the short -L option is not tested or it is not tested with arguments. Add additionl tests in t0009-dmesg.t t1008-kvs-eventlog.t t2230-job-info-lookup.t t3303-system-healthcheck.t
82bfc7a
to
2384382
Compare
Problem: Several flux commands support a --color option. However, a short option (-L) is inconsistently supported. In addition to this inconsistency, the options to --color are optional and may not always work with the short option.
For consistency across flux tools, only support the long --color option.
Update tests that tested the -L short option.
Update manpages and remove refernce to -L short option.
Fixes #5828