retch_cli/cli.rs
1// SPDX-License-Identifier: GPL-3.0-or-later
2// Copyright (C) 2026 l1a
3
4//! Command-line interface definitions.
5//!
6//! Defines the CLI arguments, flags, and options using the `clap` crate.
7
8use clap::{Parser, ValueEnum};
9
10/// Command-line arguments for retch.
11#[derive(Parser, Debug)]
12#[command(author, version, about, long_about = None)]
13pub struct Cli {
14 /// Output mode: short, long, or custom
15 #[arg(short, long, default_value = "long")]
16 pub mode: Option<String>,
17
18 /// Use a specific theme
19 #[arg(short, long)]
20 pub theme: Option<String>,
21
22 /// Path to custom config file
23 #[arg(short, long)]
24 pub config: Option<String>,
25
26 /// Force a specific distribution logo by name/ID
27 #[arg(short, long)]
28 pub logo: Option<String>,
29
30 /// Disable logo
31 #[arg(long)]
32 pub no_logo: bool,
33
34 /// Show only ASCII logo (even if graphics are supported)
35 #[arg(long)]
36 pub ascii_only: bool,
37
38 /// Short output mode (OS, Kernel, Host, CPU, GPU, Memory, Disk)
39 #[arg(long)]
40 pub short: bool,
41
42 /// Long output mode (show all fields)
43 #[arg(long)]
44 pub long: bool,
45
46 /// List available themes
47 #[arg(long)]
48 pub list_themes: bool,
49
50 /// Print an example custom theme template
51 #[arg(long)]
52 pub print_theme_template: bool,
53
54 /// List known distros
55 #[arg(long)]
56 pub list_distros: bool,
57
58 /// Print logos for known distros
59 #[arg(long)]
60 pub print_logos: bool,
61
62 /// Print default config (commented) to stdout
63 #[arg(long)]
64 pub generate_config: bool,
65
66 /// Write default config to a file (uses default location if no path given)
67 #[arg(long)]
68 pub write_config: bool,
69
70 /// Path(s) to write the config file to. Only the first value is used.
71 #[arg(trailing_var_arg = true, num_args = 0..)]
72 pub write_config_path: Vec<String>,
73
74 /// Merge default settings (as comments) into existing config
75 #[arg(long)]
76 pub merge_config: bool,
77
78 /// Fields to display (comma separated). Overrides config
79 #[arg(long)]
80 pub fields: Option<String>,
81
82 /// Generate shell completions
83 #[arg(long, value_enum)]
84 pub completions: Option<CompletionShell>,
85}
86
87/// Supported shells for completion generation.
88#[derive(ValueEnum, Clone, Debug)]
89pub enum CompletionShell {
90 Bash,
91 Elvish,
92 Fish,
93 #[clap(name = "power-shell")]
94 PowerShell,
95 Zsh,
96 Nushell,
97}