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