add command completion generation
This commit is contained in:
parent
b78a37a8a4
commit
1d1a94b30e
5 changed files with 48 additions and 3 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -94,6 +94,15 @@ dependencies = [
|
|||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11611dca53440593f38e6b25ec629de50b14cdfa63adc0fb856115a2c6d97595"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.18"
|
||||
|
@ -174,6 +183,7 @@ name = "disk-read-benchmark"
|
|||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"csv",
|
||||
"curl",
|
||||
"rand",
|
||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.20", features = ["cargo", "derive"] }
|
||||
clap_complete = "4.5.37"
|
||||
csv = "1.3.0"
|
||||
curl = "0.4.47"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -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…
Reference in a new issue