about summary refs log tree commit diff stats
path: root/pkgs/by-name/ts/tskm/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ts/tskm/src/cli.rs39
1 files changed, 35 insertions, 4 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs
index 99c8693e..1c72b3c2 100644
--- a/pkgs/by-name/ts/tskm/src/cli.rs
+++ b/pkgs/by-name/ts/tskm/src/cli.rs
@@ -1,9 +1,12 @@
 use std::path::PathBuf;
 
-use clap::{Parser, Subcommand};
+use anyhow::{bail, Result};
+use clap::{ArgAction, Parser, Subcommand};
+use url::Url;
 
 use crate::{
     interface::{input::Input, project::ProjectName},
+    state::State,
     task,
 };
 
@@ -21,6 +24,14 @@ use crate::{
 pub struct CliArgs {
     #[command(subcommand)]
     pub command: Command,
+
+    /// Increase message verbosity
+    #[arg(long="verbose", short = 'v', action = ArgAction::Count, default_value_t = 2)]
+    pub verbosity: u8,
+
+    /// Silence all output
+    #[arg(long, short = 'q')]
+    pub quiet: bool,
 }
 
 #[derive(Subcommand, Debug)]
@@ -66,7 +77,21 @@ pub enum ProjectCommand {
 #[derive(Subcommand, Debug, Clone, Copy)]
 pub enum NeorgCommand {
     /// Open the `neorg` project associated with id of the task.
-    Task { id: task::Id },
+    Task {
+        /// The working set id of the task
+        #[arg(value_parser = task_from_working_set_id)]
+        id: task::Task,
+    },
+}
+
+fn task_from_working_set_id(id: &str) -> Result<task::Task> {
+    let id: usize = id.parse()?;
+    let mut state = State::new_ro()?;
+
+    let Some(task) = task::Task::from_working_set(id, &mut state)? else {
+        bail!("Working set id '{id}' is not valid!")
+    };
+    Ok(task)
 }
 
 #[derive(Subcommand, Debug)]
@@ -80,14 +105,20 @@ pub enum OpenCommand {
     Project {
         /// The project to open.
         #[arg(value_parser = task::Project::from_project_string)]
-        project: Option<task::Project>,
+        project: task::Project,
+
+        /// The URL to open.
+        url: Option<Url>,
     },
 
     /// Open a selected project in it's Firefox profile.
     ///
     /// This will use rofi's dmenu mode to select one project from the list of all registered
     /// projects.
-    Select,
+    Select {
+        /// The URL to open.
+        url: Option<Url>,
+    },
 
     /// List all open tabs in the project.
     ListTabs {