command_vault/cli/args.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
/// Enable debug mode to see detailed command execution information
#[arg(short, long)]
pub debug: bool,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Add a command to history
///
/// Parameters can be specified using @name:description=default syntax
/// Examples:
/// - Basic parameter: @filename
/// - With description: @filename:Name of file to create
/// - With default: @filename:Name of file to create=test.txt
Add {
/// Tags to add to the command
#[arg(short, long)]
tags: Vec<String>,
/// Command to add
#[arg(trailing_var_arg = true, required = true)]
command: Vec<String>,
},
/// Execute a command by id (in the current shell)
Exec {
/// Command ID to execute
command_id: i64,
/// Enable debug mode
#[arg(long)]
debug: bool,
},
/// Search through command history
Search {
/// Search query
#[arg(required = true)]
query: String,
/// Maximum number of results to show
#[arg(short, long, default_value = "10")]
limit: usize,
},
/// List all commands in chronological order
Ls {
/// Maximum number of results to show. Use 0 to show all commands.
#[arg(short, long, default_value = "50")]
limit: usize,
/// Sort in ascending order (oldest first)
#[arg(short = 'a', long)]
asc: bool,
},
/// Tag related operations
Tag {
#[command(subcommand)]
action: TagCommands,
},
/// Initialize shell integration
ShellInit {
/// Shell to initialize (defaults to current shell)
#[arg(short, long)]
shell: Option<String>,
},
/// Delete a command from history
Delete {
/// Command ID to delete
#[arg(required = true)]
command_id: i64,
},
}
#[derive(Subcommand, Debug)]
pub enum TagCommands {
/// Add tags to a command
Add {
/// Command ID to tag
#[arg(required = true)]
command_id: i64,
/// Tags to add
#[arg(required = true)]
tags: Vec<String>,
},
/// Remove a tag from a command
Remove {
/// Command ID to remove tag from
#[arg(required = true)]
command_id: i64,
/// Tag to remove
#[arg(required = true)]
tag: String,
},
/// List all tags and their usage count
List,
/// Search commands by tag
Search {
/// Tag to search for
#[arg(required = true)]
tag: String,
/// Maximum number of results to show
#[arg(short, long, default_value = "10")]
limit: usize,
},
}