scxctl/
cli.rs

1use clap::{Parser, Subcommand};
2use scx_loader::SchedMode;
3
4#[derive(Parser, Debug)]
5#[command(author, version, about, long_about = None)]
6pub struct Cli {
7    #[command(subcommand)]
8    pub command: Commands,
9}
10
11#[derive(Parser, Debug)]
12#[group(required = true)]
13pub struct StartArgs {
14    #[arg(short, long, help = "Scheduler to start", required = true)]
15    pub sched: String,
16    #[arg(
17        short,
18        long,
19        value_enum,
20        default_value = "auto",
21        conflicts_with = "args",
22        help = "Mode to start in"
23    )]
24    pub mode: Option<SchedMode>,
25    #[arg(
26        short,
27        long,
28        value_delimiter(','),
29        requires = "sched",
30        conflicts_with = "mode",
31        help = "Arguments to run scheduler with"
32    )]
33    pub args: Option<Vec<String>>,
34}
35
36#[derive(Parser, Debug)]
37#[group(required = true)]
38pub struct SwitchArgs {
39    #[arg(short, long, help = "Scheduler to switch to")]
40    pub sched: Option<String>,
41    #[arg(
42        short,
43        long,
44        value_enum,
45        conflicts_with = "args",
46        help = "Mode to switch to"
47    )]
48    pub mode: Option<SchedMode>,
49    #[arg(
50        short,
51        long,
52        value_delimiter(','),
53        requires = "sched",
54        conflicts_with = "mode",
55        help = "Arguments to run scheduler with"
56    )]
57    pub args: Option<Vec<String>>,
58}
59
60#[derive(Subcommand, Debug)]
61pub enum Commands {
62    #[command(about = "Get the current scheduler and mode")]
63    Get,
64    #[command(about = "List all supported schedulers")]
65    List,
66    #[command(about = "Start a scheduler in a mode or with arguments")]
67    Start {
68        #[clap(flatten)]
69        args: StartArgs,
70    },
71    #[command(about = "Switch schedulers or modes, optionally with arguments")]
72    Switch {
73        #[clap(flatten)]
74        args: SwitchArgs,
75    },
76    #[command(about = "Stop the current scheduler")]
77    Stop,
78}