forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB303c51eIvan Molodetskikh2 years ago991 commits

cli.rs68 lines, 2.0 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 /// Import environment globally to systemd and D-Bus, run D-Bus services.
19 ///
20 /// Set this flag in a systemd service started by your display manager, or when running
21 /// manually as your main compositor instance. Do not set when running as a nested window, or
22 /// on a TTY as your non-main compositor instance, to avoid messing up the global environment.
23 #[arg(long)]
24 pub session: bool,
25 /// Command to run upon compositor startup.
26 #[arg(last = true)]
27 pub command: Vec<OsString>,
28
29 #[command(subcommand)]
30 pub subcommand: Option<Sub>,
31}
32
33#[derive(Subcommand)]
34pub enum Sub {
35 /// Validate the config file.
36 Validate {
37 /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
38 #[arg(short, long)]
39 config: Option<PathBuf>,
40 },
41 /// Communicate with the running niri instance.
42 Msg {
43 #[command(subcommand)]
44 msg: Msg,
45 /// Format output as JSON.
46 #[arg(short, long)]
47 json: bool,
48 },
49 /// Cause a panic to check if the backtraces are good.
50 Panic,
51}
52
53#[derive(Subcommand)]
54pub enum Msg {
55 /// Print the version of the running niri instance.
56 Version,
57 /// List connected outputs.
58 Outputs,
59 /// Print information about the focused window.
60 FocusedWindow,
61 /// Perform an action.
62 Action {
63 #[command(subcommand)]
64 action: Action,
65 },
66 /// Request an error from the running niri instance.
67 RequestError,
68}