Complete recipe names in fish completion script (#625)

This commit is contained in:
Tobin Yehle 2020-05-03 20:35:53 -07:00 committed by GitHub
parent dc7210bca3
commit fef69a3ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,14 @@
function __fish_just_complete_recipes
just --summary 2> /dev/null | tr " " "\n" || echo ""
end
# don't suggest files right off
complete -c just -n "__fish_is_first_arg" --no-files
# complete recipes
complete -c just -a '(__fish_just_complete_recipes)'
# autogenerated completions
complete -c just -n "__fish_use_subcommand" -l color -d 'Print colorful output' -r -f -a "auto always never" complete -c just -n "__fish_use_subcommand" -l color -d 'Print colorful output' -r -f -a "auto always never"
complete -c just -n "__fish_use_subcommand" -s f -l justfile -d 'Use <JUSTFILE> as justfile.' complete -c just -n "__fish_use_subcommand" -s f -l justfile -d 'Use <JUSTFILE> as justfile.'
complete -c just -n "__fish_use_subcommand" -l set -d 'Override <VARIABLE> with <VALUE>' complete -c just -n "__fish_use_subcommand" -l set -d 'Override <VARIABLE> with <VALUE>'

View File

@ -23,6 +23,19 @@ pub(crate) enum Subcommand {
Variables, Variables,
} }
const FISH_RECIPE_COMPLETIONS: &str = r#"function __fish_just_complete_recipes
just --summary 2> /dev/null | tr " " "\n" || echo ""
end
# don't suggest files right off
complete -c just -n "__fish_is_first_arg" --no-files
# complete recipes
complete -c just -a '(__fish_just_complete_recipes)'
# autogenerated completions
"#;
const ZSH_COMPLETION_REPLACEMENTS: &[(&str, &str)] = &[ const ZSH_COMPLETION_REPLACEMENTS: &[(&str, &str)] = &[
( (
r#" _arguments "${_arguments_options[@]}" \"#, r#" _arguments "${_arguments_options[@]}" \"#,
@ -127,6 +140,10 @@ impl Subcommand {
} }
} }
if let clap::Shell::Fish = shell {
script.insert_str(0, FISH_RECIPE_COMPLETIONS);
}
println!("{}", script.trim()); println!("{}", script.trim());
Ok(()) Ok(())