1 Commits
main ... v0.1.0

Author SHA1 Message Date
Kieran Klukas
e3321a10ea feat: add shell completions 2026-02-25 19:56:39 -05:00
3 changed files with 22 additions and 1 deletions

10
Cargo.lock generated
View File

@@ -107,6 +107,15 @@ dependencies = [
"strsim",
]
[[package]]
name = "clap_complete"
version = "4.5.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c757a3b7e39161a4e56f9365141ada2a6c915a8622c408ab6bb4b5d047371031"
dependencies = [
"clap",
]
[[package]]
name = "clap_derive"
version = "4.5.55"
@@ -176,6 +185,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"clap_complete",
"crc32fast",
"hmac",
"libc",

View File

@@ -13,3 +13,4 @@ hmac = "0.12"
sha2 = "0.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
clap_complete = "4"

View File

@@ -9,7 +9,8 @@ use std::path::PathBuf;
use anyhow::{Context, Result, bail};
use clap::builder::styling::{AnsiColor, Effects, Styles};
use clap::{Parser, Subcommand};
use clap::{CommandFactory, Parser, Subcommand};
use clap_complete::Shell;
use protocol::{HSMIntf, Opcode};
const STYLES: Styles = Styles::styled()
@@ -62,6 +63,11 @@ enum TopLevel {
#[command(subcommand)]
command: HwCmd,
},
/// Generate shell completions
Completions {
/// Shell to generate completions for
shell: Shell,
},
}
// ─── Tools subcommands ───
@@ -271,6 +277,10 @@ fn run(cli: Cli) -> Result<()> {
match cli.command {
TopLevel::Tools { port, command } => run_tools(&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(())
}
}
}