| 1 | use std::ffi::OsString; |
| 2 | use std::path::PathBuf; |
| 3 | |
| 4 | use clap::{Parser, Subcommand}; |
| 5 | use niri_ipc::Action; |
| 6 | |
| 7 | use crate::utils::version; |
| 8 | |
| 9 | #[derive(Parser)] |
| 10 | #[command(author, version = version(), about, long_about = None)] |
| 11 | #[command(args_conflicts_with_subcommands = true)] |
| 12 | #[command(subcommand_value_name = "SUBCOMMAND")] |
| 13 | #[command(subcommand_help_heading = "Subcommands")] |
| 14 | pub struct Cli { |
| 15 | |
| 16 | #[arg(short, long)] |
| 17 | pub config: Option<PathBuf>, |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | #[arg(long)] |
| 24 | pub session: bool, |
| 25 | |
| 26 | #[arg(last = true)] |
| 27 | pub command: Vec<OsString>, |
| 28 | |
| 29 | #[command(subcommand)] |
| 30 | pub subcommand: Option<Sub>, |
| 31 | } |
| 32 | |
| 33 | #[derive(Subcommand)] |
| 34 | pub enum Sub { |
| 35 | |
| 36 | Validate { |
| 37 | |
| 38 | #[arg(short, long)] |
| 39 | config: Option<PathBuf>, |
| 40 | }, |
| 41 | |
| 42 | Msg { |
| 43 | #[command(subcommand)] |
| 44 | msg: Msg, |
| 45 | |
| 46 | #[arg(short, long)] |
| 47 | json: bool, |
| 48 | }, |
| 49 | |
| 50 | Panic, |
| 51 | } |
| 52 | |
| 53 | #[derive(Subcommand)] |
| 54 | pub enum Msg { |
| 55 | |
| 56 | Outputs, |
| 57 | |
| 58 | FocusedWindow, |
| 59 | |
| 60 | Action { |
| 61 | #[command(subcommand)] |
| 62 | action: Action, |
| 63 | }, |
| 64 | } |