1pub mod alias;
2pub mod category;
3pub mod list;
4pub mod open;
5pub mod report;
6pub mod script;
7pub mod system;
8pub mod time;
9
10use crate::cli::SubCmd;
11use crate::config::YamlConfig;
12use crate::constants;
13
14pub fn all_command_keywords() -> Vec<&'static str> {
17 constants::cmd::all_keywords()
18}
19
20pub fn dispatch(subcmd: SubCmd, config: &mut YamlConfig) {
22 match subcmd {
23 SubCmd::Set { alias, path } => alias::handle_set(&alias, &path, config),
25 SubCmd::Remove { alias } => alias::handle_remove(&alias, config),
26 SubCmd::Rename { alias, new_alias } => alias::handle_rename(&alias, &new_alias, config),
27 SubCmd::Modify { alias, path } => alias::handle_modify(&alias, &path, config),
28
29 SubCmd::Note { alias, category } => category::handle_note(&alias, &category, config),
31 SubCmd::Denote { alias, category } => category::handle_denote(&alias, &category, config),
32
33 SubCmd::List { part } => list::handle_list(part.as_deref(), config),
35 SubCmd::Contain { alias, containers } => system::handle_contain(&alias, containers.as_deref(), config),
36
37 SubCmd::Report { content } => report::handle_report("report", &content, config),
39 SubCmd::Reportctl { action, arg } => {
40 let mut args = vec![action];
41 if let Some(a) = arg {
42 args.push(a);
43 }
44 report::handle_report("reportctl", &args, config);
45 }
46 SubCmd::Check { line_count } => report::handle_check(line_count.as_deref(), config),
47 SubCmd::Search { line_count, target, fuzzy } => {
48 report::handle_search(&line_count, &target, fuzzy.as_deref(), config);
49 }
50
51 SubCmd::Concat { name, content } => script::handle_concat(&name, &content, config),
53
54 SubCmd::Time { function, arg } => time::handle_time(&function, &arg),
56
57 SubCmd::Log { key, value } => system::handle_log(&key, &value, config),
59 SubCmd::Change { part, field, value } => system::handle_change(&part, &field, &value, config),
60 SubCmd::Clear => system::handle_clear(),
61
62 SubCmd::Version => system::handle_version(config),
64 SubCmd::Help => system::handle_help(),
65 SubCmd::Exit => system::handle_exit(),
66 SubCmd::Completion { shell } => system::handle_completion(shell.as_deref(), config),
67 }
68}