Supporting auto complete and a build-release script
Some checks failed
CI / Test (Linux) (push) Has been cancelled
CI / Test (Windows MSVC) (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Format (push) Has been cancelled

This commit is contained in:
Eric Ratliff
2026-02-22 08:22:22 -06:00
parent fe5df7dc6d
commit ba402cc187
5 changed files with 133 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
use clap::{Parser, Subcommand};
use clap::{CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Shell};
use colored::*;
use anyhow::Result;
use anvil::version::ANVIL_VERSION;
@@ -167,6 +168,12 @@ enum Commands {
dir: Option<String>,
},
/// Generate shell completion scripts
Completions {
/// Shell to generate completions for (bash, zsh, fish, powershell)
shell: Shell,
},
/// View pin maps, assign pins, and audit wiring
Pin {
/// Capability filter (pwm, analog, spi, i2c, uart, interrupt)
@@ -228,7 +235,11 @@ fn main() -> Result<()> {
let cli = Cli::parse();
print_banner();
// Completions output must be clean -- no banner
let is_completions = matches!(cli.command, Commands::Completions { .. });
if !is_completions {
print_banner();
}
match cli.command {
Commands::New { name, template, board, list_templates, list_boards } => {
@@ -352,6 +363,11 @@ fn main() -> Result<()> {
commands::lib::list_libraries(dir.as_deref())
}
}
Commands::Completions { shell } => {
let mut cmd = Cli::command();
generate(shell, &mut cmd, "anvil", &mut std::io::stdout());
Ok(())
}
Commands::Pin {
name, pin, assign, remove, audit, brief,
generate, capabilities, init_from, mode, cs, board, dir,