use std::path::{Path, PathBuf};
use clap::{Parser, Subcommand};
#[tokio::main]
async fn main() -> std::io::Result<()> {
let cli = Cli::parse();
let default_level = if cli.troubles { "debug" } else { "info" };
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(default_level)),
)
.without_time()
.init();
match cli.command {
Commands::Init => aer::tool::init().await,
Commands::Palette => aer::tool::palette::run(),
Commands::Procs {
procs_file,
profile,
} => aer::tool::procs::run(procs_file.as_deref(), profile.as_deref()).await,
Commands::Serve { port, profile } => aer::tool::serve::run(port, profile.as_deref()).await,
Commands::Kits { command } => match command {
KitsCommand::Refresh { kit, update } => {
let config_path = Path::new(aer::tool::DEFAULT_CONFIG_FILE);
let loaded = aer::tool::load_config(config_path, None).await?;
aer::tool::kits::refresh_kits(
&loaded.kits,
&loaded.config_dir,
kit.as_deref(),
update,
)
.await
}
},
}
}
#[derive(Parser)]
#[command(name = "aer")]
#[command(about = "A command-line toolkit for creatives", long_about = None)]
struct Cli {
#[arg(long, global = true)]
troubles: bool,
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init,
Palette,
Procs {
procs_file: Option<PathBuf>,
#[arg(short, long)]
profile: Option<String>,
},
Serve {
#[arg(long, default_value = "1337")]
port: u16,
#[arg(short, long)]
profile: Option<String>,
},
Kits {
#[command(subcommand)]
command: KitsCommand,
},
}
#[derive(Subcommand)]
enum KitsCommand {
Refresh {
#[arg(long)]
kit: Option<String>,
#[arg(long)]
update: bool,
},
}