snipt_cli/
cli.rs

1use clap::{Parser, Subcommand};
2use std::env;
3
4#[derive(Parser)]
5#[command(
6    author = "Gokul <@bahdotsh>",
7    version = env!("CARGO_PKG_VERSION"),
8    about = "snipt - A text snippet expansion tool",
9    long_about = "snipt allows you to define text snippets and expand them as you type."
10)]
11pub struct Snipt {
12    #[clap(subcommand)]
13    pub commands: Option<Commands>,
14}
15
16#[derive(Subcommand)]
17pub enum Commands {
18    /// Add a new text snippet
19    Add {
20        #[clap(long, short = 's', help = "Shortcut for the snippet")]
21        shortcut: String,
22
23        #[clap(long, short = 'c', help = "The snippet text")]
24        snippet: String,
25    },
26    /// Delete a text snippet by shortcut
27    Delete {
28        #[clap(long, short, help = "Shortcut of the snippet to delete")]
29        shortcut: String,
30    },
31    /// Update an existing snippet by shortcut
32    Update {
33        #[clap(long, short = 's', help = "Shortcut of the snippet to update")]
34        shortcut: String,
35
36        #[clap(long, short = 'c', help = "New snippet text")]
37        snippet: String,
38    },
39    /// Add a new snippet interactively
40    New,
41    /// Start the daemon and API server for UI
42    Start {
43        #[clap(long, short, default_value = "3000", help = "Port for the API server")]
44        port: u16,
45    },
46    /// Stop the snipt daemon
47    Stop,
48    /// Check the status of the snipt daemon
49    Status,
50    /// List all the configs
51    List,
52    /// Start just the API server (without daemon) for the Electron UI
53    Serve {
54        #[clap(long, short, default_value = "3000", help = "Port to listen on")]
55        port: u16,
56    },
57    /// Show the API server port
58    Port,
59    /// Check if the API server is responsive
60    ApiStatus,
61    /// Diagnose API server issues
62    ApiDiagnose,
63    // Hidden command used internally to run the daemon worker
64    #[clap(hide = true)]
65    DaemonWorker,
66}