Skip to main content

retch_cli/
cli.rs

1// SPDX-FileCopyrightText: 2026 Ken Tobias
2// SPDX-License-Identifier: GPL-3.0-or-later
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(name = "retch", author, version, about, long_about = None)]
13pub struct Cli {
14    /// Output mode: short, long, or custom
15    #[arg(short, 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(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_logo: bool,
37
38    /// Force Chafa symbols output (even if graphics are supported)
39    #[arg(long)]
40    pub chafa_logo: bool,
41
42    /// Short output mode (OS, Kernel, Host, CPU, GPU, Memory, Disk)
43    #[arg(short, long)]
44    pub short: bool,
45
46    /// Long output mode (show all fields)
47    #[arg(short, long)]
48    pub long: bool,
49
50    /// List available themes
51    #[arg(long)]
52    pub list_themes: bool,
53
54    /// Print an example custom theme template
55    #[arg(long)]
56    pub print_theme_template: bool,
57
58    /// List known distros
59    #[arg(long)]
60    pub list_distros: bool,
61
62    /// Print logos for known distros
63    #[arg(long)]
64    pub print_logos: bool,
65
66    /// Print default config (commented) to stdout
67    #[arg(long)]
68    pub generate_config: bool,
69
70    /// Write default config to a file (uses default location if no path given)
71    #[arg(long)]
72    pub write_config: bool,
73
74    /// Path(s) to write the config file to. Only the first value is used.
75    #[arg(trailing_var_arg = true, num_args = 0..)]
76    pub write_config_path: Vec<String>,
77
78    /// Merge default settings (as comments) into existing config
79    #[arg(long)]
80    pub merge_config: bool,
81
82    /// Fields to display (comma separated). Overrides config
83    #[arg(long)]
84    pub fields: Option<String>,
85
86    /// Location for weather lookup (city name, ZIP code, airport code, or coordinates). Overrides config
87    #[arg(long)]
88    pub weather_location: Option<String>,
89
90    /// Generate shell completions
91    #[arg(long, value_enum)]
92    pub completions: Option<CompletionShell>,
93}
94
95/// Supported shells for completion generation.
96#[derive(ValueEnum, Clone, Debug)]
97pub enum CompletionShell {
98    Bash,
99    Elvish,
100    Fish,
101    #[clap(name = "power-shell")]
102    PowerShell,
103    Zsh,
104    Nushell,
105}