about summary refs log tree commit diff stats
path: root/pkgs/by-name/ts/tskm/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ts/tskm/src/main.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkgs/by-name/ts/tskm/src/main.rs b/pkgs/by-name/ts/tskm/src/main.rs
new file mode 100644
index 00000000..77f2dcca
--- /dev/null
+++ b/pkgs/by-name/ts/tskm/src/main.rs
@@ -0,0 +1,41 @@
+use anyhow::Result;
+use clap::{CommandFactory, Parser};
+
+use crate::{
+    cli::{CliArgs, Command},
+    interface::{input, neorg, open, project},
+    state::State,
+};
+
+pub mod cli;
+pub mod interface;
+pub mod rofi;
+pub mod state;
+pub mod task;
+
+fn main() -> Result<(), anyhow::Error> {
+    clap_complete::CompleteEnv::with_factory(CliArgs::command).complete();
+
+    let args = CliArgs::parse();
+
+    stderrlog::new()
+        .module(module_path!())
+        .quiet(args.quiet)
+        .show_module_names(true)
+        .color(stderrlog::ColorChoice::Auto)
+        .verbosity(usize::from(args.verbosity))
+        .timestamp(stderrlog::Timestamp::Off)
+        .init()
+        .expect("Let's just hope that this does not panic");
+
+    let mut state = State::new_rw()?;
+
+    match args.command {
+        Command::Inputs { command } => input::handle(command)?,
+        Command::Neorg { command } => neorg::handle(command, &mut state)?,
+        Command::Open { command } => open::handle(command, &mut state)?,
+        Command::Projects { command } => project::handle(command)?,
+    }
+
+    Ok(())
+}