Skip to main content

quick_links_rofi/
cli.rs

1use clap_derive::Parser;
2
3use crate::config::{Config, I3Switcher};
4
5#[derive(Parser)]
6pub struct Cli {
7    #[clap(short, long)]
8    pub input_file: Option<String>,
9
10    #[clap(short, long)]
11    pub theme_path: Option<String>,
12
13    #[clap(short, long)]
14    pub separator: Option<char>,
15
16    #[clap(short, long)]
17    pub browser: Option<String>,
18
19    #[clap(long)]
20    pub i3: Option<u8>,
21}
22
23impl Cli {
24    pub fn update_config(self, mut config: Config) -> Config {
25        if let Some(input_file) = self.input_file {
26            config.input_file = input_file;
27        }
28        if let Some(theme_path) = self.theme_path {
29            config.theme = theme_path;
30        }
31        if let Some(separator) = self.separator {
32            config.separator = separator;
33        }
34
35        if let Some(browser) = self.browser {
36            config.browser_command_name = browser;
37        }
38
39        if let Some(workspace_number) = self.i3 {
40            config.workspace_switcher = Some(I3Switcher::new(workspace_number).into())
41        }
42
43        config
44    }
45}