Skip to content
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

Add remaining completion files #67

Merged
merged 2 commits into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fab"
version = "0.4.1"
version = "0.4.2"
authors = ["Shaishav Gandhi <[email protected]>"]
edition = "2018"

Expand Down
18 changes: 10 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::preferences::Preferences;
use clap::{App, Arg};

pub const VERSION: &str = "0.4.1";
pub const VERSION: &str = "0.4.2";

/// Builds the App with commands and defaults.
pub fn build_cli(preferences: &Preferences) -> App {
Expand Down Expand Up @@ -94,15 +94,17 @@ pub fn build_cli(preferences: &Preferences) -> App {
.author("Shaishav <[email protected]>"),
)
.subcommand(
App::new("autocomplete")
.about("Add autocomplete suggestions for vim")
.version(VERSION)
.author("Shaishav <[email protected]>"),
)
.subcommand(
App::new("generate-bash-completions")
App::new("generate-shell-completions")
.about("Generate the bash completion files for fab")
.version(VERSION)
.arg(
Arg::with_name("shell")
.short('s')
.long("shell")
.required(true)
.help("Pass the shell for which you want completions")
.possible_values(&["bash", "zsh", "fish", "elvish", "powershell"]),
)
.author("Shaishav <[email protected]>"),
)
}
35 changes: 25 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@ fn main() -> Result<(), Error> {
summary::process_summary(matches, &config, &preferences)?;
} else if let Some(matches) = matches.subcommand_matches("configure") {
preferences::process_configuration(matches)?;
} else if let Some(_matches) = matches.subcommand_matches("generate-bash-completions") {
generate::<Bash, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout());
} else if let Some(_matches) = matches.subcommand_matches("generate-zsh-completions") {
generate::<Zsh, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout());
} else if let Some(_matches) = matches.subcommand_matches("generate-fish-completions") {
generate::<Fish, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout());
} else if let Some(_matches) = matches.subcommand_matches("generate-elvish-completions") {
generate::<Elvish, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout());
} else if let Some(_matches) = matches.subcommand_matches("generate-powershell-completions") {
generate::<PowerShell, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout());
} else if let Some(matches) = matches.subcommand_matches("generate-shell-completions") {
let shell = matches
.value_of("shell")
.expect("No shell specified for generating completions");

match shell {
"bash" => {
generate::<Bash, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout())
}
"zsh" => {
generate::<Zsh, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout())
}
"fish" => {
generate::<Fish, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout())
}
"elvish" => {
generate::<Elvish, _>(&mut cli::build_cli(&preferences), "fab", &mut io::stdout())
}
"powershell" => generate::<PowerShell, _>(
&mut cli::build_cli(&preferences),
"fab",
&mut io::stdout(),
),
_ => return Err(failure::err_msg("No matching shell specified")),
}
}
Ok(())
}
Expand Down