mod cmd;
mod config;
mod utils;
use clap::{Parser, Subcommand};
use cmd::{handle_hist, handle_jobs, handle_list_jobs, handle_login, handle_logs, handle_price};
#[derive(Parser)]
#[command(name = "cluster")]
#[command(about = "A collection of cluster management commands")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Login,
Price,
Logs {
selector: Option<String>,
#[arg(short = 'o', long = "out")]
out: bool,
#[arg(short = 'l', long = "log")]
log: bool,
#[arg(short = 'e', long = "err")]
err: bool,
#[arg(short = 'n', long = "lines")]
lines: Option<i64>,
},
Ls,
Jobs,
Hist {
#[arg(short = 'n', long = "num", default_value_t = 10)]
num: usize,
},
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Commands::Login => handle_login()?,
Commands::Price => handle_price()?,
Commands::Logs {
selector,
out,
log,
err,
lines,
} => handle_logs(selector, out, log, err, lines)?,
Commands::Ls => handle_list_jobs()?,
Commands::Jobs => handle_jobs()?,
Commands::Hist { num } => handle_hist(Some(num))?,
}
Ok(())
}