use clap::Parser;
use clap_complete::Shell;
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(
name = "gctl",
author,
version = gflow::build_info::version(),
about = "Control gflow scheduler at runtime"
)]
#[command(styles = gflow::utils::STYLES)]
pub struct GCtl {
#[command(subcommand)]
pub command: Commands,
#[arg(long, global = true, hide = true)]
pub config: Option<PathBuf>,
}
#[derive(Debug, Parser)]
pub enum Commands {
SetGpus {
gpu_spec: String,
},
ShowGpus,
GpuProcess {
#[command(subcommand)]
command: GpuProcessCommands,
},
SetLimit {
job_or_group_id: String,
limit: usize,
},
Reserve {
#[command(subcommand)]
command: ReserveCommands,
},
Completion {
#[arg(value_enum)]
shell: Shell,
},
}
#[derive(Debug, Parser)]
pub enum GpuProcessCommands {
Ignore {
#[arg(long)]
gpu: u32,
#[arg(long)]
pid: u32,
},
Unignore {
#[arg(long)]
gpu: u32,
#[arg(long)]
pid: u32,
},
List,
}
#[derive(Debug, Parser)]
pub enum ReserveCommands {
Create {
#[arg(long)]
user: String,
#[arg(long, conflicts_with = "gpu_spec")]
gpus: Option<u32>,
#[arg(long, conflicts_with = "gpus")]
gpu_spec: Option<String>,
#[arg(long)]
start: String,
#[arg(long)]
duration: String,
#[arg(long)]
timezone: Option<String>,
},
List {
#[arg(long)]
user: Option<String>,
#[arg(long)]
status: Option<String>,
#[arg(long)]
active: bool,
#[arg(long)]
timeline: bool,
#[arg(
long,
value_name = "RANGE",
requires = "timeline",
conflicts_with_all = ["from", "to"]
)]
range: Option<String>,
#[arg(
long,
value_name = "TIME",
requires_all = ["timeline", "to"],
conflicts_with = "range"
)]
from: Option<String>,
#[arg(
long,
value_name = "TIME",
requires_all = ["timeline", "from"],
conflicts_with = "range"
)]
to: Option<String>,
},
Get {
id: u32,
},
Cancel {
id: u32,
},
}