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
make status
saner vis-a-vis arg parsing
#3526
Conversation
The `status` command currently silently allows incompatible flags (i.e., subcommands). Too, using flags to specify subcommands misleads the user into thinking they can specify multiple subcommands. We recently modified the `history` command to deprecate using flags for subcommands. This change does the same for the `status` command. Fixes #3509
If we're going to change it, I think that there should be a more rational set of shared subcommands. Like |
I disagree since that will merely make parsing the command more difficult should we decide to allow flags that are specific to a subset of subcommands. Not to mention greatly complicating the code to maintain backward compatibility with the existing flags. We're not inventing a DSL (domain specific language) here where that sort of grammar could be justified. You're overthinking this. |
Also, there is absolutely nothing to be gained in this situation from using |
Otherwise, I don't really see much advantage to changing this. It seems unnecessary. |
See my comment in the issue about how using flags misleads people into thinking they can specify more than one to select multiple subcommands. It's also inconsistent with how most other commands (e.g., |
This change does not force anyone to switch from the flag to non-flag form for selecting a subcommand. At least not until we bump the major version and perhaps not even then. It simply makes it much clearer that you can only specify a single subcommand per invocation. |
Also, in case it isn't already clear, this change (and the equivalent change to the |
@floam: For what the status command offers, that'd just be annoying. We currently have 7 "is" tests, 3 things that print some introspection stuff and one thing that sets an option. So you'd do Personally, I'm not a huge fan of either of these, but if it works I'll accept it since @krader1961 wants it. @krader1961: One thing this is lacking is an update to the completions. We can do that later, though. |
Also, one piece of weird behavior: > status is-interactive --current-filename
status: current-filename expected 0 args, got 1 i.e. the error is about the last operation, where I'd expect it to be about the first. |
Actually, that particular combination should complain about specifying two subcommands in the same invocation. Pretty sure I know what I did wrong. I made the same mistake with the I actually started working on revamping the completions but wanted to get the core of the change out for feedback. Completions will be updated later today. We certainly don't have to introduce non-flag subcommands in order to fix the core problem. But imagine if we had made the |
This updates the completions for the `status` command. It also corrects the handling by the builtin `history` and `status` commands of a subcommand specified via both a flag and a non-flag argument.
@faho: Please review the updated the completions. The one thing I couldn't figure out is how to inhibit file name completion after a subcommand is seen which doesn't require, or accept, any further arguments. |
|
||
function __fish_status_needs_job_ctrl_cmd |
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 is basically just __fish_seen_subcommand_from job-control
.
# The job-control command changes fish state. | ||
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a job-control -d "Set which jobs are under job control" | ||
complete -f -c status -n "__fish_status_needs_job_ctrl_cmd" -a full -d "Set all jobs under job control" | ||
complete -f -c status -n "__fish_status_needs_job_ctrl_cmd" --no-files -a interactive -d "Set only interactive jobs under job control" |
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.
These "--no-files" are duplicates of the earlier "-f".
Currently, you don't - see #112. The rest seems logically okay, I just had two nits. |
Merged as 9e922a6. |
case STATUS_PRINT_STACK_TRACE: | ||
return L"print-stack-trace"; | ||
} | ||
} |
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.
openSUSE builds are complaining about no return in the default case again, and failing to build.
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'm just about to create a PR that generalizes that code using table driven template methods. That should take care of those false positives.
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.
Also, any chance we can setup an existing or new Travis build environment to use the same tool chain so we can get Travis to tell us about these problems?
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.
Well, "problems" => "non-problems" except in so far as they break the OBS build 😄
Note
Now that we have two sets of functions that perform string-to-enum and enum-to-string translations it makes sense to generalize this and make functions that take a table which defines the legal mappings. I'll do that in a separate change.
Description
The
status
command currently silently allows incompatible flags (i.e.,subcommands). Too, using flags to specify subcommands misleads the user
into thinking they can specify multiple subcommands.
We recently modified the
history
command to deprecate using flags forsubcommands. This change does the same for the
status
command.Fixes #3509