fix: single source of truth for version across crate and tests
Replace all hardcoded "1.1.0" version strings with env!("CARGO_PKG_VERSION")
in src/, so Cargo.toml is the sole source for the built binary. Tests
intentionally use a separate hardcoded constant in tests/common.rs to act
as a canary — they will fail on a version bump until manually updated.
- src/project/mod.rs: add WEEVIL_VERSION const, wire into Tera context,
generated README, and .weevil-version marker
- tests/common.rs: new file, holds EXPECTED_VERSION for all test crates
- tests/{integration,project_lifecycle,unit/config_tests}.rs: pull from
common instead of env! or inline literals
This commit is contained in:
69
src/main.rs
69
src/main.rs
@@ -1,6 +1,7 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
use colored::*;
|
||||
use anyhow::Result;
|
||||
use weevil::version::WEEVIL_VERSION;
|
||||
|
||||
mod commands;
|
||||
mod sdk;
|
||||
@@ -9,9 +10,12 @@ mod templates;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "weevil")]
|
||||
#[command(author = "Eric Barch <eric@intrepidfusion.com>")]
|
||||
#[command(version = "1.0.0")]
|
||||
#[command(about = "FTC robotics project generator - bores into complexity, emerges with clean code", long_about = None)]
|
||||
#[command(author = "Eric Ratliff <eric@nxlearn.net>")]
|
||||
#[command(version = WEEVIL_VERSION)]
|
||||
#[command(
|
||||
about = "FTC robotics project generator - bores into complexity, emerges with clean code",
|
||||
long_about = None
|
||||
)]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
@@ -23,71 +27,71 @@ enum Commands {
|
||||
New {
|
||||
/// Name of the robot project
|
||||
name: String,
|
||||
|
||||
|
||||
/// Path to FTC SDK (optional, will auto-detect or download)
|
||||
#[arg(long)]
|
||||
ftc_sdk: Option<String>,
|
||||
|
||||
|
||||
/// Path to Android SDK (optional, will auto-detect or download)
|
||||
#[arg(long)]
|
||||
android_sdk: Option<String>,
|
||||
},
|
||||
|
||||
|
||||
/// Check system health and diagnose issues
|
||||
Doctor,
|
||||
|
||||
|
||||
/// Setup development environment (system or project)
|
||||
Setup {
|
||||
/// Path to project directory (optional - without it, sets up system)
|
||||
path: Option<String>,
|
||||
},
|
||||
|
||||
|
||||
/// Remove Weevil-installed SDKs and dependencies
|
||||
Uninstall {
|
||||
/// Show what would be removed without actually removing anything
|
||||
#[arg(long)]
|
||||
dry_run: bool,
|
||||
|
||||
|
||||
/// Remove only specific items by number (use --dry-run first to see the list)
|
||||
#[arg(long, value_name = "NUM", num_args = 1..)]
|
||||
only: Option<Vec<usize>>,
|
||||
},
|
||||
|
||||
|
||||
/// Upgrade an existing project to the latest generator version
|
||||
Upgrade {
|
||||
/// Path to the project directory
|
||||
path: String,
|
||||
},
|
||||
|
||||
|
||||
/// Build and deploy project to Control Hub
|
||||
Deploy {
|
||||
/// Path to the project directory
|
||||
path: String,
|
||||
|
||||
|
||||
/// Force USB connection
|
||||
#[arg(long)]
|
||||
usb: bool,
|
||||
|
||||
|
||||
/// Force WiFi connection
|
||||
#[arg(long)]
|
||||
wifi: bool,
|
||||
|
||||
|
||||
/// Custom IP address
|
||||
#[arg(short, long)]
|
||||
ip: Option<String>,
|
||||
},
|
||||
|
||||
|
||||
/// Manage SDKs (FTC and Android)
|
||||
Sdk {
|
||||
#[command(subcommand)]
|
||||
command: SdkCommands,
|
||||
},
|
||||
|
||||
|
||||
/// Show or update project configuration
|
||||
Config {
|
||||
/// Path to the project directory
|
||||
path: String,
|
||||
|
||||
|
||||
/// Set FTC SDK path for this project
|
||||
#[arg(long, value_name = "PATH")]
|
||||
set_sdk: Option<String>,
|
||||
@@ -98,10 +102,10 @@ enum Commands {
|
||||
enum SdkCommands {
|
||||
/// Install required SDKs
|
||||
Install,
|
||||
|
||||
|
||||
/// Show SDK status and locations
|
||||
Status,
|
||||
|
||||
|
||||
/// Update SDKs to latest versions
|
||||
Update,
|
||||
}
|
||||
@@ -110,11 +114,11 @@ fn main() -> Result<()> {
|
||||
// Enable colors on Windows
|
||||
#[cfg(windows)]
|
||||
colored::control::set_virtual_terminal(true).ok();
|
||||
|
||||
|
||||
let cli = Cli::parse();
|
||||
|
||||
|
||||
print_banner();
|
||||
|
||||
|
||||
match cli.command {
|
||||
Commands::New { name, ftc_sdk, android_sdk } => {
|
||||
commands::new::create_project(&name, ftc_sdk.as_deref(), android_sdk.as_deref())
|
||||
@@ -134,13 +138,11 @@ fn main() -> Result<()> {
|
||||
Commands::Deploy { path, usb, wifi, ip } => {
|
||||
commands::deploy::deploy_project(&path, usb, wifi, ip.as_deref())
|
||||
}
|
||||
Commands::Sdk { command } => {
|
||||
match command {
|
||||
SdkCommands::Install => commands::sdk::install_sdks(),
|
||||
SdkCommands::Status => commands::sdk::show_status(),
|
||||
SdkCommands::Update => commands::sdk::update_sdks(),
|
||||
}
|
||||
}
|
||||
Commands::Sdk { command } => match command {
|
||||
SdkCommands::Install => commands::sdk::install_sdks(),
|
||||
SdkCommands::Status => commands::sdk::show_status(),
|
||||
SdkCommands::Update => commands::sdk::update_sdks(),
|
||||
},
|
||||
Commands::Config { path, set_sdk } => {
|
||||
if let Some(sdk_path) = set_sdk {
|
||||
commands::config::set_sdk(&path, &sdk_path)
|
||||
@@ -153,8 +155,13 @@ fn main() -> Result<()> {
|
||||
|
||||
fn print_banner() {
|
||||
println!("{}", "═══════════════════════════════════════════════════════════".bright_cyan());
|
||||
println!("{}", " 🪲 Weevil - FTC Project Generator v1.0.0".bright_cyan().bold());
|
||||
println!(
|
||||
"{}",
|
||||
format!(" 🪲 Weevil - FTC Project Generator v{}", WEEVIL_VERSION)
|
||||
.bright_cyan()
|
||||
.bold()
|
||||
);
|
||||
println!("{}", " Nexus Workshops LLC".bright_cyan());
|
||||
println!("{}", "═══════════════════════════════════════════════════════════".bright_cyan());
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user