Skip to content

Commit

Permalink
Prepare for making shell completion functionality generic over shell
Browse files Browse the repository at this point in the history
This change prepares the shell-complete utility program to be generic
over the shell to use. Specifically, we rename the generate_bash
function to generate_for_shell and pass in the shell to use.
  • Loading branch information
d-e-s-o committed Mar 21, 2021
1 parent 26570e1 commit b8018cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions var/shell-complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ struct Args {
command: String,
}

fn generate_bash<W>(command: &str, output: &mut W)
fn generate_for_shell<W>(command: &str, shell: clap::Shell, output: &mut W)
where
W: io::Write,
{
let mut app = nitrocli::Args::clap();
app.gen_completions_to(command, clap::Shell::Bash, output);
app.gen_completions_to(command, shell, output);
}

fn main() {
let args = Args::from_args();
generate_bash(&args.command, &mut io::stdout())
generate_for_shell(&args.command, clap::Shell::Bash, &mut io::stdout())
}

#[cfg(test)]
Expand Down Expand Up @@ -92,7 +92,7 @@ mod tests {
W: ExactSizeIterator<Item = &'w str>,
{
let mut buffer = Vec::new();
generate_bash("nitrocli", &mut buffer);
generate_for_shell("nitrocli", clap::Shell::Bash, &mut buffer);

let script = String::from_utf8(buffer).unwrap();
let command = format!(
Expand Down

0 comments on commit b8018cc

Please sign in to comment.