Skip to content

Commit

Permalink
Add remaining completion files (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaishavGandhi committed Apr 26, 2020
1 parent 7158bfd commit b867464
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
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 <shaishavgandhi05@gmail.com>"]
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 <shaishavgandhi05@gmail.com>"),
)
.subcommand(
App::new("autocomplete")
.about("Add autocomplete suggestions for vim")
.version(VERSION)
.author("Shaishav <shaishavgandhi05@gmail.com>"),
)
.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 <shaishavgandhi05@gmail.com>"),
)
}
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

0 comments on commit b867464

Please sign in to comment.