use std::sync::LazyLock; use clap::{ArgAction, Parser, Subcommand}; pub static CONFIG: LazyLock = LazyLock::new(|| Args::parse()); #[derive(Debug, Parser)] #[clap(author, version)] #[command(help_template = "{author-section}\n{usage-heading} {usage}\n\n{all-args}")] pub struct Args { #[command(subcommand)] pub command: Command, } #[derive(Debug, Subcommand)] pub enum Command { /// Create a new raven project New { project_name: String }, /// Create a new raven project in an existing directory Init, /// Compile the current project Build, /// Run the current project #[command(arg_required_else_help = true)] Run { #[arg(required = true)] entry_point: String, #[clap(flatten)] assertions: Assertions, }, /// !!! BORKED !!! Run the tests Test { #[clap(flatten)] assertions: Assertions, }, /// Remove the target directory and caching Clean, } impl Command { pub fn depends_on_nest(&self) -> bool { match self { Self::Init | Self::New { .. } => false, _ => true, } } } #[derive(Debug, clap::Args)] pub struct Assertions { /// Disable assertions. #[arg(short, long = "no-assert", action = ArgAction::SetFalse)] disable_assert: bool, } impl Into for &Assertions { fn into(self) -> bool { !self.disable_assert } }