1use std::collections::HashMap;
2
3#[derive(Debug, Clone)]
4pub enum CommandCategory {
5 Media,
6 Dev,
7 Search,
8 Text,
9 Data,
10 Fs,
11 Archive,
12 Sys,
13 Net,
14 Crypto,
15 Docker,
16 Calc,
17 Qr,
18 Color,
19 Timer,
20 Note,
21 Clipboard,
22 Unix,
23 Code,
24 Sem,
25 Context,
26 AutoRun,
27 AutoDebug,
28 Config,
29 Repl,
30 Help,
31}
32
33#[derive(Debug, Clone)]
34pub struct Command {
35 pub category: CommandCategory,
36 pub action: String,
37 pub args: Vec<String>,
38 pub flags: HashMap<String, String>,
39 pub switches: Vec<String>,
40}
41
42impl Command {
43 pub fn new(category: CommandCategory, action: impl Into<String>) -> Self {
44 Self {
45 category,
46 action: action.into(),
47 args: Vec::new(),
48 flags: HashMap::new(),
49 switches: Vec::new(),
50 }
51 }
52
53 pub fn with_args(mut self, args: Vec<String>) -> Self {
54 self.args = args;
55 self
56 }
57
58 pub fn with_flag(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
59 self.flags.insert(key.into(), value.into());
60 self
61 }
62
63 pub fn with_switch(mut self, s: impl Into<String>) -> Self {
64 self.switches.push(s.into());
65 self
66 }
67}