| 1 | use clap::{Parser, Subcommand, ValueEnum}; |
| 2 | use std::path::PathBuf; |
| 3 | |
| 4 | #[derive(Parser)] |
| 5 | #[command(name = "gump")] |
| 6 | #[command(author, version, about = "A smarter cd command - zoxide without the z")] |
| 7 | #[command(propagate_version = true)] |
| 8 | pub struct Cli { |
| 9 | #[command(subcommand)] |
| 10 | pub command: Commands, |
| 11 | } |
| 12 | |
| 13 | #[derive(Subcommand)] |
| 14 | pub enum Commands { |
| 15 | /// Add a directory to the database |
| 16 | Add { |
| 17 | /// Path to add (defaults to current directory) |
| 18 | #[arg(default_value = ".")] |
| 19 | path: PathBuf, |
| 20 | }, |
| 21 | |
| 22 | /// Query the database for matching directories |
| 23 | Query { |
| 24 | /// Search terms |
| 25 | #[arg(required = true)] |
| 26 | terms: Vec<String>, |
| 27 | |
| 28 | /// Show frecency scores |
| 29 | #[arg(short, long)] |
| 30 | score: bool, |
| 31 | |
| 32 | /// Show all matches instead of just the best |
| 33 | #[arg(short, long)] |
| 34 | all: bool, |
| 35 | |
| 36 | /// Match against current directory contents instead of database |
| 37 | #[arg(long)] |
| 38 | cwd: bool, |
| 39 | }, |
| 40 | |
| 41 | /// Remove a directory from the database |
| 42 | Remove { |
| 43 | /// Path to remove |
| 44 | path: PathBuf, |
| 45 | }, |
| 46 | |
| 47 | /// List all directories in the database |
| 48 | List { |
| 49 | /// Show frecency scores |
| 50 | #[arg(short, long)] |
| 51 | score: bool, |
| 52 | }, |
| 53 | |
| 54 | /// Remove directories that no longer exist |
| 55 | Clean, |
| 56 | |
| 57 | /// Generate shell integration code |
| 58 | Init { |
| 59 | /// Shell to generate code for |
| 60 | shell: Shell, |
| 61 | |
| 62 | /// Custom command name (default: g) |
| 63 | #[arg(long, default_value = "g")] |
| 64 | cmd: String, |
| 65 | |
| 66 | /// When to update the database |
| 67 | #[arg(long, default_value = "pwd")] |
| 68 | hook: Hook, |
| 69 | |
| 70 | /// Only output hooks, no command aliases |
| 71 | #[arg(long)] |
| 72 | no_cmd: bool, |
| 73 | }, |
| 74 | |
| 75 | /// Import directories from zoxide |
| 76 | Import, |
| 77 | |
| 78 | /// Edit the database in your editor |
| 79 | Edit, |
| 80 | } |
| 81 | |
| 82 | #[derive(Clone, ValueEnum)] |
| 83 | pub enum Shell { |
| 84 | Bash, |
| 85 | Zsh, |
| 86 | Fish, |
| 87 | } |
| 88 | |
| 89 | #[derive(Clone, ValueEnum)] |
| 90 | pub enum Hook { |
| 91 | /// Update on every prompt |
| 92 | Prompt, |
| 93 | /// Update when directory changes |
| 94 | Pwd, |
| 95 | } |
| 96 |