use clap::{ArgAction, Parser, Subcommand};
use eyre::Result;
use crate::up::UpCommand;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
#[arg(long, short, action = ArgAction::Count, default_value = "2")]
v: u8,
#[clap(subcommand)]
pub command: Option<Command>,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Up(UpCommand),
Down,
Nuke,
Clean,
List,
Deps,
}
pub fn run() -> Result<()> {
let Args { v, command } = Args::parse();
crate::telemetry::init_tracing_subscriber(v)?;
crate::banners::banner()?;
match command {
None => UpCommand::new(None, false).run(),
Some(command) => match command {
Command::Up(up_command) => up_command.run(),
Command::List => crate::list::run(),
Command::Down => unimplemented!("down command not yet implemented"),
Command::Nuke => unimplemented!("nuke command not yet implemented"),
Command::Clean => unimplemented!("clean command not yet implemented"),
Command::Deps => {
tracing::info!(target: "opup", "Installing dependencies...");
crate::runner::run_until_ctrl_c(async {
crate::deps::DependencyManager::sync().await
})?;
tracing::info!(target: "opup", "Dependencies installed.");
Ok(())
}
},
}
}