Supporting auto complete and a build-release script
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user