Supporting multiple boards

This commit is contained in:
Eric Ratliff
2026-02-19 10:12:33 -06:00
parent 2739d83b99
commit b909da298e
16 changed files with 1554 additions and 94 deletions

View File

@@ -45,7 +45,11 @@ enum Commands {
},
/// Check system health and diagnose issues
Doctor,
Doctor {
/// Automatically install missing tools
#[arg(long)]
fix: bool,
},
/// Install arduino-cli and required cores
Setup,
@@ -81,6 +85,36 @@ enum Commands {
#[arg(long)]
force: bool,
},
/// Manage board profiles in .anvil.toml
Board {
/// Board name (e.g. mega, nano)
name: Option<String>,
/// Add a board to the project
#[arg(long, conflicts_with_all = ["remove", "listall"])]
add: bool,
/// Remove a board from the project
#[arg(long, conflicts_with_all = ["add", "listall"])]
remove: bool,
/// Browse all available boards
#[arg(long, conflicts_with_all = ["add", "remove"])]
listall: bool,
/// Board identifier (from anvil board --listall)
#[arg(long, value_name = "ID")]
id: Option<String>,
/// Baud rate override
#[arg(long, value_name = "RATE")]
baud: Option<u32>,
/// Path to project directory (defaults to current directory)
#[arg(long, short = 'd', value_name = "DIR")]
dir: Option<String>,
},
}
fn main() -> Result<()> {
@@ -113,8 +147,8 @@ fn main() -> Result<()> {
);
}
}
Commands::Doctor => {
commands::doctor::run_diagnostics()
Commands::Doctor { fix } => {
commands::doctor::run_diagnostics(fix)
}
Commands::Setup => {
commands::setup::run_setup()
@@ -143,6 +177,38 @@ fn main() -> Result<()> {
force,
)
}
Commands::Board { name, add, remove, listall, id, baud, dir } => {
if listall {
commands::board::listall_boards(name.as_deref())
} else if add {
let board_name = name.as_deref().ok_or_else(|| {
anyhow::anyhow!(
"Board name required.\n\
Usage: anvil board --add mega\n\
Browse available boards: anvil board --listall"
)
})?;
commands::board::add_board(
board_name,
id.as_deref(),
baud,
dir.as_deref(),
)
} else if remove {
let board_name = name.as_deref().ok_or_else(|| {
anyhow::anyhow!(
"Board name required.\n\
Usage: anvil board --remove mega"
)
})?;
commands::board::remove_board(
board_name,
dir.as_deref(),
)
} else {
commands::board::list_boards(dir.as_deref())
}
}
}
}