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 /// Open the PR for the current branch in the browser
54 Open,
55
56 /// Manage worktrees
57 Worktree {
58 #[command(subcommand)]
59 command: WorktreeCommands,
60 },
61}
62
63#[derive(Subcommand)]
64pub enum WorktreeCommands {
65 /// Manage a pre-warmed worktree pool
66 Pool {
67 #[command(subcommand)]
68 command: PoolCommands,
69 },
70}
71
72#[derive(Subcommand)]
73pub enum PoolCommands {
74 /// Pre-warm the pool with ready-to-use worktrees
75 Warm {
76 /// Target number of available worktrees in the pool
77 count: usize,
78 },
79
80 /// Acquire a worktree from the pool (prints path to stdout)
81 Acquire,
82
83 /// Show pool status
84 Status,
85
86 /// Release acquired worktree(s) back to the pool
87 Release {
88 /// Name of the worktree to release (defaults to all acquired)
89 name: Option<String>,
90 },
91
92 /// Remove all worktrees and clean up the pool
93 Drain {
94 /// Force drain even if worktrees are acquired
95 #[arg(long)]
96 force: bool,
97 },
98}