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