add command completion generation
This commit is contained in:
parent
b78a37a8a4
commit
1d1a94b30e
5 changed files with 48 additions and 3 deletions
|
@ -8,7 +8,14 @@ pub struct Cli {
|
|||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
#[derive(Debug)]
|
||||
pub enum Commands {
|
||||
///Generate bash completions
|
||||
GenerateBashCompletions,
|
||||
///Generate zsh completions
|
||||
GenerateZshCompletions,
|
||||
///Generate fish completions
|
||||
GenerateFishCompletions,
|
||||
///Grabs the datasets used for benchmarking
|
||||
GrabData,
|
||||
///Runs the benchmark
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pub mod dataset_gathering;
|
||||
pub mod benchmarks;
|
||||
pub mod cli;
|
||||
pub mod cli;
|
||||
pub mod dataset_gathering;
|
||||
|
|
29
src/main.rs
29
src/main.rs
|
@ -1,7 +1,9 @@
|
|||
use clap::Parser;
|
||||
use clap::{CommandFactory, Parser};
|
||||
use clap_complete::aot::{generate, Bash, Fish, Zsh};
|
||||
use disk_read_benchmark::benchmarks::benchmark;
|
||||
use disk_read_benchmark::cli::*;
|
||||
use disk_read_benchmark::dataset_gathering::*;
|
||||
use std::io::stdout;
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
@ -22,5 +24,30 @@ fn main() {
|
|||
grab_datasets().unwrap(); // * should unwrap
|
||||
benchmark();
|
||||
}
|
||||
// I can't be bothered to do this how I *should*, rather than hardcoding it
|
||||
Commands::GenerateBashCompletions => {
|
||||
generate(
|
||||
Bash,
|
||||
&mut Cli::command(),
|
||||
"disk-read-benchmark",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
Commands::GenerateZshCompletions => {
|
||||
generate(
|
||||
Zsh,
|
||||
&mut Cli::command(),
|
||||
"disk-read-benchmark",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
Commands::GenerateFishCompletions => {
|
||||
generate(
|
||||
Fish,
|
||||
&mut Cli::command(),
|
||||
"disk-read-benchmark",
|
||||
&mut stdout(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue