forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiBbefdebfIvan Molodetskikh2 years ago681 commits

cli.rs55 lines, 1.3 KiBHistoryRawDownload
1use std::ffi::OsString;
2use std::path::PathBuf;
3
4use clap::{Parser, Subcommand};
5use niri_ipc::Action;
6
7use 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")]
14pub struct Cli {
15 /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
16 #[arg(short, long)]
17 pub config: Option<PathBuf>,
18 /// Command to run upon compositor startup.
19 #[arg(last = true)]
20 pub command: Vec<OsString>,
21
22 #[command(subcommand)]
23 pub subcommand: Option<Sub>,
24}
25
26#[derive(Subcommand)]
27pub enum Sub {
28 /// Validate the config file.
29 Validate {
30 /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
31 #[arg(short, long)]
32 config: Option<PathBuf>,
33 },
34 /// Communicate with the running niri instance.
35 Msg {
36 #[command(subcommand)]
37 msg: Msg,
38 /// Format output as JSON.
39 #[arg(short, long)]
40 json: bool,
41 },
42 /// Cause a panic to check if the backtraces are good.
43 Panic,
44}
45
46#[derive(Subcommand)]
47pub enum Msg {
48 /// List connected outputs.
49 Outputs,
50 /// Perform an action.
51 Action {
52 #[command(subcommand)]
53 action: Action,
54 },
55}