blob: 2049686ba6f3a645109247e3ce82d17a9a8a7e02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
use crate::{app::App, configuration::SettingsBuilder};
use anyhow::Result;
use clap::{Parser, ValueEnum};
#[derive(Parser)]
pub struct Args {
command: Command,
}
#[derive(Parser, Clone, Copy, ValueEnum)]
enum Command {
/// Reset the configuration to default
Reset,
/// Set the mode to vi
SetViMode,
/// Set the mode to normal
SetNormalMode,
/// Set the icons to special characters
SetSpecialIcons,
/// Set the icons to char
SetCharIcons,
}
pub fn run(mut app: App, args: Args) -> Result<()> {
let Args { command } = args;
match command {
Command::Reset => {
let mut sb = SettingsBuilder::default();
sb.save_to_file()?;
app.settings = sb.build();
}
Command::SetViMode => {
app.settings.set_vi_mode();
}
Command::SetNormalMode => {
app.settings.set_normal_mode();
}
Command::SetSpecialIcons => {
app.settings.set_special_icons();
}
Command::SetCharIcons => {
app.settings.set_char_icons();
}
}
Ok(())
}
|