diff --git a/bin/opup/src/cli.rs b/bin/opup/src/cli.rs index 7e9d6ec..aa7ad65 100644 --- a/bin/opup/src/cli.rs +++ b/bin/opup/src/cli.rs @@ -1,30 +1,50 @@ -use clap::{ArgAction, Parser}; +use clap::{ArgAction, Parser, Subcommand}; use eyre::Result; use std::path::PathBuf; /// Command line arguments #[derive(Parser, Debug)] -#[command(author, version, about)] +#[command(author, version, about, long_about = None)] pub struct Args { /// Verbosity level (0-4) #[arg(long, short, action = ArgAction::Count, default_value = "2")] v: u8, + + /// The subcommand to run + #[clap(subcommand)] + pub command: Option, + /// An optional path to a stack config file. #[arg(long, short)] config: Option, } +/// Possible CLI subcommands +#[derive(Debug, Subcommand)] +pub enum Command { + /// Build and run the devnet stack + Up, + /// Bring the devnet stack down + Down, + /// Nuke the devnet stack + Nuke, + /// Clean all stack artifacts + Clean, +} + pub fn run() -> Result<()> { - let Args { v, config } = Args::parse(); + let Args { v, config, command } = Args::parse(); crate::telemetry::init_tracing_subscriber(v)?; crate::banners::banner()?; - // todo: switch on subcommands - // default should be to run the devnet stack - // should also allow nuking the devnet - // and stopping an already running devnet + match command { + Some(Command::Up) | None => crate::stack::Stack::new(config).run()?, + Some(Command::Down) => unimplemented!("down command not yet implemented"), + Some(Command::Nuke) => unimplemented!("nuke command not yet implemented"), + Some(Command::Clean) => unimplemented!("clean command not yet implemented"), + } - crate::stack::Stack::new(config).run() + Ok(()) }