-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90e1b6b
commit 84ce227
Showing
1 changed file
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Command>, | ||
|
||
/// An optional path to a stack config file. | ||
#[arg(long, short)] | ||
config: Option<PathBuf>, | ||
} | ||
|
||
/// 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(()) | ||
} |