okey/cli/
mod.rs

1pub mod commands;
2
3mod utils;
4
5use clap::Parser;
6
7#[derive(Parser, Debug)]
8#[command(version, about)]
9pub struct Cli {
10    #[command(subcommand)]
11    pub command: Command,
12}
13
14#[derive(Parser, Debug)]
15pub enum Command {
16    /// Start the keyboard remapping hook
17    Start {
18        /// Configuration file path (default: ~/.config/okey/config.yaml)
19        #[arg(short, long)]
20        config: Option<String>,
21        /// Whether to start the process as a daemon
22        #[arg(short, long, default_value_t = false)]
23        daemon: bool,
24
25        #[arg(
26            long,
27            hide_short_help = true,
28            hide_long_help = true,
29            default_value_t = false
30        )]
31        systemd: bool,
32    },
33
34    /// Utility commands for the systemd service
35    Service {
36        #[command(subcommand)]
37        command: SystemdSubcommand,
38    },
39
40    /// Utility commands for debugging input devices
41    Device {
42        #[command(subcommand)]
43        command: DeviceSubcommand,
44    },
45}
46
47#[derive(Parser, Debug)]
48pub enum SystemdSubcommand {
49    /// Shorthand for 'systemctl --user enable okey && systemctl --user start okey'
50    Start,
51    /// Shorthand for 'systemctl --user stop okey && systemctl --user disable okey'
52    Stop,
53    /// Shorthand for 'systemctl --user restart okey'
54    Restart,
55    /// Shorthand for 'systemctl --user status okey'
56    Status,
57    /// Create the systemd service file
58    Install,
59    /// Disable and remove the service file
60    Uninstall,
61}
62
63#[derive(Parser, Debug)]
64pub enum DeviceSubcommand {
65    /// List all input devices that support keys
66    List {
67        /// Whether to only show keyboards
68        #[arg(short, long, default_value_t = false)]
69        keyboard: bool,
70    },
71}