-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
adds completion for the default Elm cli tool #10759
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
Conversation
EmilyGraceSeville7cf
left a comment
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.
Please respond to my comments, I try to do my best while reviewing the code. 😄
| @@ -0,0 +1,24 @@ | |||
| set -l commands repl init reactor make install bump diff publish | |||
|
|
|||
| complete -c elm -f | |||
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.
Personally, I would recommend putting elm in the variable like set -l command elm. However, till the command name is short and not gonna change then this solution may be pretty fine. 😄
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 wouldn't do that, this completion file will only ever work for elm.
My position on that idiom is that it's fake flexibility. You're never gonna change that one line to make it magically work for something else - the most common case is something like python/python2/python3, where you can use complete --wraps to reuse one completion script.
Or the tool renames itself entirely, and you just rename the file and do s/-c elm/-c banana/ on it.
So the variable gives you one additional line and a lot of $command everywhere for no real benefit.
| # repl completions | ||
| complete -c elm -n "not __fish_seen_subcommand_from $commands" -a repl -d 'Open up an interactive programming session' | ||
| complete -c elm -n "__fish_seen_subcommand_from repl" -l no-colors -d 'Turn off the colors in REPL' | ||
| complete -c elm -n "__fish_seen_subcommand_from repl" -l interpreter= -d 'Path to an alternative JS interpreter' |
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.
-l interpreter= for me looks a little bit suspicious, if you wanna an option to be assignable via = sign then don't add -r flag to complete.
| # repl completions | ||
| complete -c elm -n "not __fish_seen_subcommand_from $commands" -a repl -d 'Open up an interactive programming session' | ||
| complete -c elm -n "__fish_seen_subcommand_from repl" -l no-colors -d 'Turn off the colors in REPL' | ||
| complete -c elm -n "__fish_seen_subcommand_from repl" -l interpreter= -d 'Path to an alternative JS interpreter' |
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 would rather put "__fish_seen_subcommand_from repl" in a some variable like so: set -l repl_condition "__fish_seen_subcommand_from repl".
| complete -c elm -n "not __fish_seen_subcommand_from $commands" -a diff -d 'See what changed in a package between different versions' | ||
| complete -c elm -n "not __fish_seen_subcommand_from $commands" -a publish -d 'Publishes your package on package.elm-lang.org so anyone in the community can use it' | ||
|
|
||
| complete -c elm -l help -d "Show a more detailed description" |
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.
From my personal experience, I suggest moving -h|--help and -v|--version options always to the top. The point being that user should always be able to quickly understand how to get some help (although the mentioned flags are common, however, sometimes they vary a little bit).
elm's argument parser copes just fine without them Review comment from #10759 (comment)
|
Cherry-picked into 4.0 as 7ea368b with fixup suggested by @EmilyGraceSeville7cf as 1b6e107 |
elm's argument parser copes just fine without them Review comment from #10759 (comment) (cherry picked from commit 2849cd1)
Add completion for the default CLI tool for the Elm language which was lacking and neither provided for the tool authors. The completion code was written by myself.