Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3321a10ea |
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -107,6 +107,15 @@ dependencies = [
|
|||||||
"strsim",
|
"strsim",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_complete"
|
||||||
|
version = "4.5.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c757a3b7e39161a4e56f9365141ada2a6c915a8622c408ab6bb4b5d047371031"
|
||||||
|
dependencies = [
|
||||||
|
"clap",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.55"
|
version = "4.5.55"
|
||||||
@@ -176,6 +185,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"hmac",
|
"hmac",
|
||||||
"libc",
|
"libc",
|
||||||
|
|||||||
@@ -13,3 +13,4 @@ hmac = "0.12"
|
|||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
clap_complete = "4"
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -9,7 +9,8 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
use anyhow::{Context, Result, bail};
|
use anyhow::{Context, Result, bail};
|
||||||
use clap::builder::styling::{AnsiColor, Effects, Styles};
|
use clap::builder::styling::{AnsiColor, Effects, Styles};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{CommandFactory, Parser, Subcommand};
|
||||||
|
use clap_complete::Shell;
|
||||||
use protocol::{HSMIntf, Opcode};
|
use protocol::{HSMIntf, Opcode};
|
||||||
|
|
||||||
const STYLES: Styles = Styles::styled()
|
const STYLES: Styles = Styles::styled()
|
||||||
@@ -62,6 +63,11 @@ enum TopLevel {
|
|||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: HwCmd,
|
command: HwCmd,
|
||||||
},
|
},
|
||||||
|
/// Generate shell completions
|
||||||
|
Completions {
|
||||||
|
/// Shell to generate completions for
|
||||||
|
shell: Shell,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Tools subcommands ───
|
// ─── Tools subcommands ───
|
||||||
@@ -271,6 +277,10 @@ fn run(cli: Cli) -> Result<()> {
|
|||||||
match cli.command {
|
match cli.command {
|
||||||
TopLevel::Tools { port, command } => run_tools(&port, command),
|
TopLevel::Tools { port, command } => run_tools(&port, command),
|
||||||
TopLevel::Hw { port, command } => run_hw(&port, command),
|
TopLevel::Hw { port, command } => run_hw(&port, command),
|
||||||
|
TopLevel::Completions { shell } => {
|
||||||
|
clap_complete::generate(shell, &mut Cli::command(), "ectf-tools", &mut std::io::stdout());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user