aboutsummaryrefslogtreecommitdiffstats
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.rs68
1 files changed, 27 insertions, 41 deletions
diff --git a/pkgs/by-name/ts/tskm/src/main.rs b/pkgs/by-name/ts/tskm/src/main.rs
index 7fc9c0d4..a852bd7b 100644
--- a/pkgs/by-name/ts/tskm/src/main.rs
+++ b/pkgs/by-name/ts/tskm/src/main.rs
@@ -1,64 +1,50 @@
-#![allow(clippy::missing_panics_doc)]
-#![allow(clippy::missing_errors_doc)]
+// nixos-config - My current NixOS configuration
+//
+// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// This file is part of my nixos-config.
+//
+// You should have received a copy of the License along with this program.
+// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
use anyhow::Result;
-use clap::Parser;
+use clap::{CommandFactory, Parser};
-use crate::interface::{input, neorg, open, project};
+use crate::{
+ cli::{CliArgs, Command},
+ interface::{input, neorg, open, project},
+ state::State,
+};
+pub mod browser;
pub mod cli;
pub mod interface;
pub mod rofi;
+pub mod state;
pub mod task;
-use crate::cli::{CliArgs, Command};
+#[tokio::main]
+async fn main() -> Result<(), anyhow::Error> {
+ clap_complete::CompleteEnv::with_factory(CliArgs::command).complete();
-fn main() -> Result<(), anyhow::Error> {
- // TODO: Support these completions for the respective types <2025-04-04>
- //
- // ID_GENERATION_FUNCTION
- // ```sh
- // context="$(task _get rc.context)"
- // if [ "$context" ]; then
- // filter="project:$context"
- // else
- // filter="0-10000"
- // fi
- // tasks="$(task "$filter" _ids)"
- //
- // if [ "$tasks" ]; then
- // echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}'
- // fi
- // ```
- //
- // ARGUMENTS:
- // ID | *([0-9]) := [[%ID_GENERATION_FUNCTION]]
- // The function displays all possible IDs of the eligible tasks.
- //
- // WS := %ALL_WORKSPACES
- // All possible workspaces.
- //
- // P := %ALL_PROJECTS_PIPE
- // The possible project.
- //
- // F := [[fd . --max-depth 3]]
- // A URL-Input file to use as source.
let args = CliArgs::parse();
stderrlog::new()
.module(module_path!())
- .quiet(false)
+ .quiet(args.quiet)
.show_module_names(true)
.color(stderrlog::ColorChoice::Auto)
- .verbosity(5)
- .timestamp(stderrlog::Timestamp::Off)
+ .verbosity(usize::from(args.verbosity))
.init()
.expect("Let's just hope that this does not panic");
+ let mut state = State::new_rw().await?;
+
match args.command {
- Command::Inputs { command } => input::handle(command)?,
- Command::Neorg { command } => neorg::handle(command)?,
- Command::Open { command } => open::handle(command)?,
+ Command::Inputs { command } => input::handle(command, &mut state).await?,
+ Command::Neorg { command } => neorg::handle(command, &mut state).await?,
+ Command::Open { command } => open::handle(command, &mut state).await?,
Command::Projects { command } => project::handle(command)?,
}