Supports switching default board

This commit is contained in:
Eric Ratliff
2026-02-19 10:23:16 -06:00
parent b909da298e
commit 6cacc07109
9 changed files with 456 additions and 16 deletions

View File

@@ -92,15 +92,19 @@ enum Commands {
name: Option<String>,
/// Add a board to the project
#[arg(long, conflicts_with_all = ["remove", "listall"])]
#[arg(long, conflicts_with_all = ["remove", "listall", "default"])]
add: bool,
/// Remove a board from the project
#[arg(long, conflicts_with_all = ["add", "listall"])]
#[arg(long, conflicts_with_all = ["add", "listall", "default"])]
remove: bool,
/// Set the default board
#[arg(long, conflicts_with_all = ["add", "remove", "listall"])]
default: bool,
/// Browse all available boards
#[arg(long, conflicts_with_all = ["add", "remove"])]
#[arg(long, conflicts_with_all = ["add", "remove", "default"])]
listall: bool,
/// Board identifier (from anvil board --listall)
@@ -177,7 +181,7 @@ fn main() -> Result<()> {
force,
)
}
Commands::Board { name, add, remove, listall, id, baud, dir } => {
Commands::Board { name, add, remove, default, listall, id, baud, dir } => {
if listall {
commands::board::listall_boards(name.as_deref())
} else if add {
@@ -205,6 +209,18 @@ fn main() -> Result<()> {
board_name,
dir.as_deref(),
)
} else if default {
let board_name = name.as_deref().ok_or_else(|| {
anyhow::anyhow!(
"Board name required.\n\
Usage: anvil board --default uno\n\
List boards: anvil board"
)
})?;
commands::board::set_default_board(
board_name,
dir.as_deref(),
)
} else {
commands::board::list_boards(dir.as_deref())
}