Rust · 2036 bytes Raw Blame History
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 (optional with --all)
25 terms: Vec<String>,
26
27 /// Show frecency scores
28 #[arg(short, long)]
29 score: bool,
30
31 /// Show all matches instead of just the best
32 #[arg(short, long)]
33 all: bool,
34
35 /// Match against current directory contents instead of database
36 #[arg(long)]
37 cwd: bool,
38 },
39
40 /// Remove a directory from the database
41 Remove {
42 /// Path to remove
43 path: PathBuf,
44 },
45
46 /// List all directories in the database
47 List {
48 /// Show frecency scores
49 #[arg(short, long)]
50 score: bool,
51 },
52
53 /// Remove directories that no longer exist
54 Clean,
55
56 /// Generate shell integration code
57 Init {
58 /// Shell to generate code for
59 shell: Shell,
60
61 /// Custom command name (default: g)
62 #[arg(long, default_value = "g")]
63 cmd: String,
64
65 /// When to update the database
66 #[arg(long, default_value = "pwd")]
67 hook: Hook,
68
69 /// Only output hooks, no command aliases
70 #[arg(long)]
71 no_cmd: bool,
72 },
73
74 /// Import directories from zoxide
75 Import,
76
77 /// Edit the database in your editor
78 Edit,
79 }
80
81 #[derive(Clone, ValueEnum)]
82 pub enum Shell {
83 Bash,
84 Zsh,
85 Fish,
86 }
87
88 #[derive(Clone, ValueEnum)]
89 pub enum Hook {
90 /// Update on every prompt
91 Prompt,
92 /// Update when directory changes
93 Pwd,
94 }
95