-
Notifications
You must be signed in to change notification settings - Fork 38
Add plugin subcommand to generate shell completions #173
Conversation
Currently the new subcommand has the following spec: art tools [FLAGS] [OPTIONS] <value> Where [FLAGS] are the standard -v, -q, -h, [OPTIONS] takes -o for output file/directory in addition to --work-tree. Currently <value> can be any of, 'bash-completions', 'fish-completions', 'zsh-completions', or 'ps-completions', each of which uses clap's completion generation feature to create tab completion files for bash, fish, zsh, and PowerShell respectively.
I think this looks good. I'll test it out shortly. I think I would like to change The changes would be:
|
also, we've hit 1.0! I'm going to implement a beta channel to release this on while it is tested, stay tuned. |
also, sorry about the code churn here. You pushed this just as I was releasing 1.0, clearly I wasn't ready for contributions of new features! |
Code churn is fine. I have a project that I was going to start soon, and this looked like a great tool for it, but the two things that really help make commandline tools useful for me are good shell completions and man pages. I figured it wouldn't be much work to add the completion generation, but man pages are harder. |
thanks for your patience. I've almost got the feature stream ready. I'll be pushing a PR and making sure it passes on travis. Should be ready in a few hours. |
ok, the beta channel has been added. Let me know if you hit any issues or have any confusion. The functions |
Pick up beta feature changes just enough so that a featureless cargo check passes.
It looks like travis failed with an Rerun? |
Go for it. I can't from here, just ammend your commit message and push -f
|
36f4250
to
0876f19
Compare
Notable changes include the signature of run_beta, as some commands may not need a project, and some commands need access to the io::Write object passed to 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.
I can do the TODO, otherwise looks great! Thanks for doing this :)
} | ||
|
||
#[cfg(not(feature = "beta"))] | ||
/// run beta commands in the `[#cfg(feature = "beta")]` function | ||
fn run_beta(_: &Project, _: &ArgMatches) -> Result<u8> { | ||
fn run_beta<W>(_: Option<&Project>, _: &ArgMatches, _: &mut W) -> Result<u8> |
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.
lol, Project
does have to be an option... doesn't it!
src/cmd/plugin.rs
Outdated
Arg::with_name("name") | ||
.required(true) | ||
.possible_values(&[ | ||
"bash-completions", |
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.
TODO: make these constants. I can tackle if you are busy.
static BASH_COMPLETIONS: &str = "bash-completions";
... etc
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 think we want const
not static
, with const
the match expression can be
BASH_COMPLETIONS => Plugin::Comp(Shell::Bash),
FISH_COMPLETIONS => Plugin::Comp(Shell::Fish),
ZSH_COMPLETIONS => Plugin::Comp(Shell::Zsh),
PS_COMPLETIONS => Plugin::Comp(Shell::PowerShell),
...
as the const
effectively inlines the constant. Otherwise we would need to do something like
x if x == BASH_COMPLETIONS => Plugin::Comp(Shell::Bash),
x if x == FISH_COMPLETIONS => Plugin::Comp(Shell::Fish),
x if x == ZSH_COMPLETIONS => Plugin::Comp(Shell::Zsh),
x if x == PS_COMPLETIONS => Plugin::Comp(Shell::PowerShell),
...
I'm not certain what this becomes, but it seems less elegant for serving the same purpose.
Incorporate review comments. Also fix miscellaneous clippy comments.
Looks good, I didn't actually realize you could use I haven't tested this locally, but it's behind the beta flag so I'm going to merge it and test it out later. Thanks for putting this together. |
This is a followup to #168. Enough changes were made for me to warrant creating a new PR.
I implemented this as a
tools
subcommand after my attempt to make it an option ofexport
had the unfortunate side effect of needing to have an artifact project initialized in order to use commands that did not need to have an associated project.