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.rs115
1 files changed, 115 insertions, 0 deletions
diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs
new file mode 100644
index 00000000..958033b3
--- /dev/null
+++ b/pkgs/by-name/ts/tskm/src/cli.rs
@@ -0,0 +1,115 @@
+use std::path::PathBuf;
+
+use clap::{Parser, Subcommand};
+
+use crate::{
+    interface::{input::Input, project::ProjectName},
+    task,
+};
+
+#[derive(Parser, Debug)]
+#[command(author, version, about, long_about, verbatim_doc_comment)]
+/// This is the core interface to the system-integrated task management
+///
+/// `tskm` effectively combines multiple applications together:
+/// - `taskwarrior` projects are raised connected to `firefox` profiles, making it possible to “open”
+///   a project.
+/// - Every `taskwarrior` project has a determined `neorg` path, so that extra information for a
+///   `project` can be stored in this `norg` file.
+/// - `tskm` can track inputs for you. These are URLs with optional tags which you can that
+///   “review” to open tasks based on them.
+pub struct CliArgs {
+    #[command(subcommand)]
+    pub command: Command,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum Command {
+    /// Interact with projects.
+    Projects {
+        #[command(subcommand)]
+        command: ProjectCommand,
+    },
+
+    /// Manage the input queue.
+    Inputs {
+        #[command(subcommand)]
+        command: InputCommand,
+    },
+
+    /// Access the associated `neorg` workspace for the project/task.
+    Neorg {
+        #[command(subcommand)]
+        command: NeorgCommand,
+    },
+
+    /// Interface with the Firefox profile of each project.
+    Open {
+        #[command(subcommand)]
+        command: OpenCommand,
+    },
+}
+
+#[derive(Subcommand, Debug)]
+pub enum ProjectCommand {
+    /// Lists all available projects.
+    List,
+
+    /// Allows you to quickly add projects.
+    Add {
+        /// The name of the new project.
+        #[arg(value_parser = ProjectName::try_from_project)]
+        new_project_name: ProjectName,
+    },
+}
+
+#[derive(Subcommand, Debug, Clone, Copy)]
+pub enum NeorgCommand {
+    /// Open the `neorg` project associated with id of the task.
+    Task { id: task::Id },
+}
+
+#[derive(Subcommand, Debug)]
+pub enum OpenCommand {
+    /// Open each project's Firefox profile consecutively, that was opened since the last review.
+    ///
+    /// This allows you to remove stale opened tabs and to commit open tabs to the `inputs`.
+    Review,
+
+    /// Opens Firefox with either the supplied project or the currently active project profile.
+    Project {
+        /// The project to open.
+        #[arg(value_parser = task::Project::from_project_string)]
+        project: Option<task::Project>,
+    },
+
+    /// 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,
+}
+
+#[derive(Subcommand, Debug)]
+pub enum InputCommand {
+    /// Add URLs as inputs to be categorized.
+    Add { inputs: Vec<Input> },
+    /// Remove URLs
+    Remove { inputs: Vec<Input> },
+
+    /// Add all URLs in the file as inputs to be categorized.
+    ///
+    /// This expects each line to contain one URL.
+    File { file: PathBuf },
+
+    /// Like 'review', but for the inputs that have previously been added.
+    /// It takes a project in which to open the URLs.
+    Review {
+        /// Opens all the URLs in this project.
+        #[arg(value_parser = task::Project::from_project_string)]
+        project: task::Project,
+    },
+
+    /// List all the previously added inputs.
+    List,
+}