git_workflow/cli.rs
1//! CLI argument parsing with clap
2
3use clap::{Parser, Subcommand};
4
5#[derive(Parser)]
6#[command(name = "gw")]
7#[command(about = "Git workflow CLI - type-safe worktree-aware git operations")]
8#[command(version)]
9pub struct Cli {
10 #[command(subcommand)]
11 pub command: Commands,
12
13 /// Show verbose output (git commands being run)
14 #[arg(short, long, global = true)]
15 pub verbose: bool,
16}
17
18#[derive(Subcommand)]
19pub enum Commands {
20 /// Switch to home branch and sync with origin/main
21 Home,
22
23 /// Create new branch from origin/main
24 New {
25 /// Name of the branch to create (e.g., feature/add-login)
26 branch: Option<String>,
27 },
28
29 /// Delete merged branch and return to home
30 Cleanup {
31 /// Branch to delete (defaults to current branch if not on home)
32 branch: Option<String>,
33 },
34
35 /// Show current repository state
36 Status,
37
38 /// Pause current work: WIP commit and return to home branch
39 Pause {
40 /// Optional message describing why work is paused
41 message: Option<String>,
42 },
43
44 /// Abandon current changes and return to home branch
45 Abandon,
46
47 /// Undo the last commit (soft reset HEAD~1)
48 Undo,
49
50 /// Sync current branch after base PR is merged (update base to main, rebase, force push)
51 Sync,
52
53 /// Manage worktrees
54 Worktree {
55 #[command(subcommand)]
56 command: WorktreeCommands,
57 },
58}
59
60#[derive(Subcommand)]
61pub enum WorktreeCommands {
62 /// Manage a pre-warmed worktree pool
63 Pool {
64 #[command(subcommand)]
65 command: PoolCommands,
66 },
67}
68
69#[derive(Subcommand)]
70pub enum PoolCommands {
71 /// Pre-warm the pool with ready-to-use worktrees
72 Warm {
73 /// Target number of available worktrees in the pool
74 count: usize,
75 },
76
77 /// Acquire a worktree from the pool (prints path to stdout)
78 Acquire,
79
80 /// Show pool status
81 Status,
82
83 /// Release acquired worktree(s) back to the pool
84 Release {
85 /// Name of the worktree to release (defaults to all acquired)
86 name: Option<String>,
87 },
88
89 /// Remove all worktrees and clean up the pool
90 Drain {
91 /// Force drain even if worktrees are acquired
92 #[arg(long)]
93 force: bool,
94 },
95}