Skip to main content

prompt_store/
cli.rs

1//! Defines the command-line interface structure using clap.
2
3use clap::{Parser, Subcommand};
4
5#[derive(Parser)]
6#[command(name = "prompt-store", version, about = "Encrypted prompts manager")]
7pub struct Cli {
8    #[command(subcommand)]
9    pub command: Cmd,
10}
11
12#[derive(Subcommand)]
13pub enum Cmd {
14    /// List all stored prompts and chains
15    List {
16        #[arg(long, help = "Filter prompts by tag(s)")]
17        tag: Vec<String>,
18    },
19    /// Create a new prompt
20    New,
21    /// Get a specific prompt by ID (including namespaced IDs like `pack::id`)
22    Get { id: String },
23    /// Edit an existing prompt
24    Edit { id: String },
25    /// Delete a prompt or chain by ID
26    Delete { id: String },
27    /// Rename a prompt's title
28    Rename {
29        id: String,
30        #[arg(long, help = "New title for the prompt")]
31        title: String,
32    },
33    /// Search prompts by query, optionally filtering by tag or content
34    Search {
35        query: String,
36        #[arg(long, help = "Filter by specific tag")]
37        tag: Option<String>,
38        #[arg(long, help = "Search in prompt content")]
39        content: bool,
40    },
41    /// Tag a prompt with one or more tags
42    #[command(about = "Tag a prompt with one or more tags")]
43    Tag { id: String, changes: Vec<String> },
44    /// Copy a prompt to clipboard
45    Copy { id: String },
46    /// Run a prompt with variable substitution
47    Run {
48        id: String,
49        #[arg(long = "var", help = "Variable assignments in key=value format")]
50        vars: Vec<String>,
51    },
52    /// Export prompts to a file
53    Export {
54        #[arg(long, help = "Comma-separated list of prompt IDs to export")]
55        ids: Option<String>,
56        #[arg(long, help = "Output file path")]
57        out: String,
58    },
59    /// Import prompts from a file
60    Import { file: String },
61    /// Show prompt revision history
62    History { id: String },
63    /// Revert a prompt to a previous version
64    Revert {
65        id: String,
66        #[arg(long, help = "Specific timestamp to revert to")]
67        timestamp: Option<String>,
68    },
69    /// Rotate the encryption key
70    RotateKey {
71        #[arg(long, help = "Protect the new key with a password")]
72        password: bool,
73    },
74    /// Manage prompt chains
75    #[command(subcommand)]
76    Chain(ChainCmd),
77    /// Manage prompt packs for sharing and deployment
78    #[command(subcommand)]
79    Pack(PackCmd),
80    /// Deploy a prompt pack from a git repository
81    Deploy {
82        /// URL of the git repository to deploy
83        repo_url: String,
84        /// Optional local alias for the pack
85        #[arg(long)]
86        alias: Option<String>,
87        /// Password for private/encrypted packs (can also be set via PROMPT_PACK_PASSWORD env var)
88        #[arg(long, env = "PROMPT_PACK_PASSWORD")]
89        password: Option<String>,
90    },
91    /// Update deployed prompt pack(s)
92    Update {
93        /// The alias of a specific pack to update. If omitted, all packs are updated.
94        alias: Option<String>,
95    },
96    /// Show store statistics
97    Stats,
98    /// Start an interactive session (REPL)
99    Interactive,
100}
101
102#[derive(Subcommand)]
103pub enum ChainCmd {
104    /// Create a new multi-step prompt chain interactively
105    New,
106    /// Edit a chain's metadata (e.g., title)
107    Edit { id: String },
108    /// Add a new step to an existing chain
109    AddStep { id: String },
110    /// Remove a step from a chain
111    RmStep {
112        #[arg(help = "The ID of the step to remove (e.g., mychain/1)")]
113        step_id: String,
114    },
115}
116
117#[derive(Subcommand)]
118pub enum PackCmd {
119    /// Export a workspace to a 'prompts.bundle' file for sharing
120    Export {
121        /// Workspace to export (defaults to 'default')
122        #[arg(long)]
123        workspace: Option<String>,
124    },
125}