Refactor CLI, add refresh command, fix port detection, add device tracking
- Remove build/upload/monitor subcommands (projects are self-contained) - Remove ctrlc dependency (only used by removed monitor watch mode) - Update next-steps messaging to reference project scripts directly - Add 'anvil refresh [DIR] [--force]' to update project scripts to latest templates without touching user code - Fix Windows port detection: replace fragile findstr/batch TOML parsing with proper comment-skipping logic; add _detect_port.ps1 helper for reliable JSON-based port detection via PowerShell - Add .anvil.local for machine-specific config (gitignored) - 'anvil devices --set [PORT] [-d DIR]' saves port + VID:PID - 'anvil devices --get [-d DIR]' shows saved port status - VID:PID tracks USB devices across COM port reassignment - Port resolution: -p flag > VID:PID > saved port > auto-detect - Uppercase normalization for Windows COM port names - Update all .bat/.sh templates to read from .anvil.local - Remove port entries from .anvil.toml (no machine-specific config in git) - Add .anvil.local to .gitignore template - Expand 'anvil devices' output with VID:PID, serial number, and usage instructions
This commit is contained in:
@@ -177,7 +177,12 @@ fn init_git(project_dir: &PathBuf, template_name: &str) {
|
||||
fn make_executable(project_dir: &PathBuf) {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let scripts = ["test/run_tests.sh"];
|
||||
let scripts = [
|
||||
"build.sh",
|
||||
"upload.sh",
|
||||
"monitor.sh",
|
||||
"test/run_tests.sh",
|
||||
];
|
||||
for script in &scripts {
|
||||
let path = project_dir.join(script);
|
||||
if path.exists() {
|
||||
@@ -196,23 +201,67 @@ fn print_next_steps(project_name: &str) {
|
||||
" 1. {}",
|
||||
format!("cd {}", project_name).bright_cyan()
|
||||
);
|
||||
println!(" 2. Check your system: {}", "anvil doctor".bright_cyan());
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
println!(
|
||||
" 2. Compile: {}",
|
||||
"build.bat".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 3. Upload to board: {}",
|
||||
"upload.bat".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 4. Upload + monitor: {}",
|
||||
"upload.bat --monitor".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 5. Serial monitor: {}",
|
||||
"monitor.bat".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 6. Run host tests: {}",
|
||||
"test\\run_tests.bat".bright_cyan()
|
||||
);
|
||||
println!();
|
||||
println!(
|
||||
" {}",
|
||||
"On Linux/macOS: ./build.sh, ./upload.sh, ./monitor.sh"
|
||||
.bright_black()
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
" 2. Compile: {}",
|
||||
"./build.sh".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 3. Upload to board: {}",
|
||||
"./upload.sh".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 4. Upload + monitor: {}",
|
||||
"./upload.sh --monitor".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 5. Serial monitor: {}",
|
||||
"./monitor.sh".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 6. Run host tests: {}",
|
||||
"./test/run_tests.sh".bright_cyan()
|
||||
);
|
||||
println!();
|
||||
println!(
|
||||
" {}",
|
||||
"On Windows: build.bat, upload.bat, monitor.bat, test\\run_tests.bat"
|
||||
.bright_black()
|
||||
);
|
||||
}
|
||||
|
||||
println!(
|
||||
" 3. Find your board: {}",
|
||||
"anvil devices".bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 4. Build and upload: {}",
|
||||
format!("anvil build {}", project_name).bright_cyan()
|
||||
);
|
||||
println!(
|
||||
" 5. Build + monitor: {}",
|
||||
format!("anvil build --monitor {}", project_name).bright_cyan()
|
||||
);
|
||||
println!();
|
||||
println!(
|
||||
" Run host tests: {}",
|
||||
"cd test && ./run_tests.sh".bright_cyan()
|
||||
" {}",
|
||||
"System check: anvil doctor | Port scan: anvil devices"
|
||||
.bright_black()
|
||||
);
|
||||
println!();
|
||||
}
|
||||
@@ -249,4 +298,4 @@ mod tests {
|
||||
let long_name = "a".repeat(51);
|
||||
assert!(validate_project_name(&long_name).is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user