pub(crate) mod list;
pub(crate) mod profile;
pub(crate) mod runtime;
pub(crate) mod state;
pub(crate) mod status;
pub(crate) mod stop;
pub(crate) mod switch;
use std::path::PathBuf;
use crate::cli::{LocalArgs, LocalCommand};
pub(crate) async fn run(args: LocalArgs) {
let base_dir = current_base_dir();
let result = match args.command {
LocalCommand::List(args) => list::run(args, &base_dir).await,
LocalCommand::Status(args) => status::run(args, &base_dir).await,
LocalCommand::Switch(args) => switch::run(args, &base_dir).await,
LocalCommand::Profile(args) => profile::run(args),
LocalCommand::Stop(args) => stop::run(args, &base_dir).await,
};
if let Err(error) = result {
eprintln!("error: {error}");
std::process::exit(1);
}
}
fn current_base_dir() -> PathBuf {
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
}