Skip to main content

vibe_ticket/cli/
commands.rs

1use clap::{Parser, Subcommand};
2
3/// vibe-ticket: A high-performance ticket management system for Vide Coding
4#[derive(Parser, Debug)]
5#[command(name = "vibe-ticket")]
6#[command(author, version, about, long_about = None)]
7#[command(propagate_version = true)]
8pub struct Cli {
9    /// Enable verbose output
10    #[arg(short, long, global = true)]
11    pub verbose: bool,
12
13    /// Use JSON output format
14    #[arg(short, long, global = true)]
15    pub json: bool,
16
17    /// Disable color output
18    #[arg(long, global = true)]
19    pub no_color: bool,
20
21    /// Path to the project directory
22    #[arg(short, long, global = true)]
23    pub project: Option<String>,
24
25    #[command(subcommand)]
26    pub command: Commands,
27}
28
29#[derive(Subcommand, Debug)]
30pub enum Commands {
31    /// Initialize a new vibe-ticket project
32    Init {
33        /// Project name
34        #[arg(short, long)]
35        name: Option<String>,
36
37        /// Project description
38        #[arg(short, long)]
39        description: Option<String>,
40
41        /// Force initialization even if already initialized
42        #[arg(short, long)]
43        force: bool,
44
45        /// Generate CLAUDE.md for AI assistance
46        #[arg(long = "claude-md", alias = "claude")]
47        claude_md: bool,
48    },
49
50    /// Create a new ticket
51    New {
52        /// Ticket slug (e.g., fix-login-bug)
53        slug: String,
54
55        /// Ticket title
56        #[arg(short, long)]
57        title: Option<String>,
58
59        /// Ticket description
60        #[arg(short, long)]
61        description: Option<String>,
62
63        /// Priority (low, medium, high, critical)
64        #[arg(long, default_value = "medium")]
65        priority: String,
66
67        /// Tags (comma-separated)
68        #[arg(long)]
69        tags: Option<String>,
70
71        /// Start working on the ticket immediately
72        #[arg(short, long)]
73        start: bool,
74    },
75
76    /// List all tickets
77    List {
78        /// Filter by status (todo, doing, done, blocked, review)
79        #[arg(short, long)]
80        status: Option<String>,
81
82        /// Filter by priority (low, medium, high, critical)
83        #[arg(long)]
84        priority: Option<String>,
85
86        /// Filter by assignee
87        #[arg(short, long)]
88        assignee: Option<String>,
89
90        /// Sort by field (created, updated, priority, status, slug)
91        #[arg(long, default_value = "slug")]
92        sort: String,
93
94        /// Reverse sort order
95        #[arg(short, long)]
96        reverse: bool,
97
98        /// Limit number of results
99        #[arg(short, long)]
100        limit: Option<usize>,
101
102        /// Show archived tickets
103        #[arg(long)]
104        archived: bool,
105
106        /// Show only open tickets (todo, doing)
107        #[arg(long)]
108        open: bool,
109
110        /// Filter tickets created since (e.g., "yesterday", "2 days ago", "2025-07-18")
111        #[arg(long)]
112        since: Option<String>,
113
114        /// Filter tickets created until (e.g., "today", "1 week ago", "2025-07-20")
115        #[arg(long)]
116        until: Option<String>,
117
118        /// Include done tickets (by default they are hidden)
119        #[arg(long)]
120        include_done: bool,
121    },
122
123    /// Show tickets in kanban board view
124    Board {
125        /// Filter by assignee
126        #[arg(short, long)]
127        assignee: Option<String>,
128
129        /// Show only active tickets
130        #[arg(long)]
131        active_only: bool,
132
133        /// Compact view (less spacing)
134        #[arg(short, long)]
135        compact: bool,
136    },
137
138    /// Start working on a ticket
139    Start {
140        /// Ticket ID or slug
141        ticket: String,
142
143        /// Create a new Git branch
144        #[arg(short, long, default_value = "true")]
145        branch: bool,
146
147        /// Custom branch name (default: ticket-{slug})
148        #[arg(long)]
149        branch_name: Option<String>,
150
151        /// Create a Git worktree (use --no-worktree to disable)
152        #[arg(long, default_value = "true")]
153        worktree: bool,
154
155        /// Disable worktree creation and only create a branch
156        #[arg(long = "no-worktree", conflicts_with = "worktree")]
157        no_worktree: bool,
158    },
159
160    /// Show open tickets (alias for list --open)
161    Open {
162        /// Sort by field (created, updated, priority, status, slug)
163        #[arg(long, default_value = "updated")]
164        sort: String,
165
166        /// Reverse sort order
167        #[arg(short, long)]
168        reverse: bool,
169
170        /// Limit number of results
171        #[arg(short, long)]
172        limit: Option<usize>,
173    },
174
175    /// Close the current ticket
176    Close {
177        /// Ticket ID or slug (defaults to active ticket)
178        ticket: Option<String>,
179
180        /// Close message
181        #[arg(short, long)]
182        message: Option<String>,
183
184        /// Archive the ticket
185        #[arg(short, long)]
186        archive: bool,
187
188        /// Create a merge/pull request
189        #[arg(long)]
190        pr: bool,
191    },
192
193    /// Mark a ticket for review
194    Review {
195        /// Ticket ID or slug (defaults to active ticket)
196        ticket: Option<String>,
197
198        /// Review notes/comments
199        #[arg(short, long)]
200        notes: Option<String>,
201    },
202
203    /// Approve a ticket and mark as done
204    Approve {
205        /// Ticket ID or slug (defaults to active ticket)
206        ticket: Option<String>,
207
208        /// Approval message
209        #[arg(short, long)]
210        message: Option<String>,
211    },
212
213    /// Request changes on a ticket
214    RequestChanges {
215        /// Ticket ID or slug (defaults to active ticket)
216        ticket: Option<String>,
217
218        /// Description of requested changes
219        #[arg(short, long)]
220        changes: String,
221    },
222
223    /// Hand off a ticket to another agent/person
224    Handoff {
225        /// Ticket ID or slug (defaults to active ticket)
226        ticket: Option<String>,
227
228        /// New assignee (agent or person name)
229        assignee: String,
230
231        /// Handoff notes
232        #[arg(short, long)]
233        notes: Option<String>,
234    },
235
236    /// Check the current status
237    Check {
238        /// Show detailed information
239        #[arg(short, long)]
240        detailed: bool,
241
242        /// Include statistics
243        #[arg(short, long)]
244        stats: bool,
245    },
246
247    /// Edit a ticket
248    Edit {
249        /// Ticket ID or slug (defaults to active ticket)
250        ticket: Option<String>,
251
252        /// New title
253        #[arg(long)]
254        title: Option<String>,
255
256        /// New description
257        #[arg(long)]
258        description: Option<String>,
259
260        /// New priority
261        #[arg(long)]
262        priority: Option<String>,
263
264        /// New status
265        #[arg(long)]
266        status: Option<String>,
267
268        /// Add tags (comma-separated)
269        #[arg(long)]
270        add_tags: Option<String>,
271
272        /// Remove tags (comma-separated)
273        #[arg(long)]
274        remove_tags: Option<String>,
275
276        /// Open in editor
277        #[arg(short, long)]
278        editor: bool,
279    },
280
281    /// Show ticket details
282    Show {
283        /// Ticket ID or slug
284        ticket: String,
285
286        /// Show tasks
287        #[arg(short, long)]
288        tasks: bool,
289
290        /// Show history
291        #[arg(long)]
292        history: bool,
293
294        /// Show in markdown format
295        #[arg(short, long)]
296        markdown: bool,
297    },
298
299    /// Manage tasks within a ticket
300    Task {
301        #[command(subcommand)]
302        command: TaskCommands,
303    },
304
305    /// Archive or unarchive tickets
306    Archive {
307        /// Ticket ID or slug
308        ticket: String,
309
310        /// Unarchive instead of archive
311        #[arg(short, long)]
312        unarchive: bool,
313    },
314
315    /// Search tickets
316    Search {
317        /// Search query
318        query: String,
319
320        /// Search in title only
321        #[arg(long)]
322        title: bool,
323
324        /// Search in description only
325        #[arg(long)]
326        description: bool,
327
328        /// Search in tags only
329        #[arg(long)]
330        tags: bool,
331
332        /// Use regex
333        #[arg(short, long)]
334        regex: bool,
335    },
336
337    /// Export tickets
338    Export {
339        /// Output format (json, yaml, csv, markdown)
340        #[arg(short, long, default_value = "json")]
341        format: String,
342
343        /// Output file (defaults to stdout)
344        #[arg(short, long)]
345        output: Option<String>,
346
347        /// Include archived tickets
348        #[arg(long)]
349        include_archived: bool,
350    },
351
352    /// Import tickets
353    Import {
354        /// Input file
355        file: String,
356
357        /// Input format (json, yaml, csv)
358        #[arg(short, long)]
359        format: Option<String>,
360
361        /// Skip validation
362        #[arg(long)]
363        skip_validation: bool,
364
365        /// Dry run (don't actually import)
366        #[arg(long)]
367        dry_run: bool,
368    },
369
370    /// Manage project configuration
371    Config {
372        #[command(subcommand)]
373        command: ConfigCommands,
374    },
375
376    /// Manage specifications (spec-driven development)
377    Spec {
378        #[command(subcommand)]
379        command: SpecCommands,
380    },
381    /// Manage Git worktrees for tickets
382    Worktree {
383        #[command(subcommand)]
384        command: WorktreeCommands,
385    },
386
387    /// Model Context Protocol (MCP) server
388    #[cfg(feature = "mcp")]
389    Mcp {
390        #[command(subcommand)]
391        command: McpCommands,
392    },
393
394    /// Bulk operations on multiple tickets
395    Bulk {
396        #[command(subcommand)]
397        command: BulkCommands,
398    },
399
400    /// Manage saved filters (views)
401    Filter {
402        #[command(subcommand)]
403        command: FilterCommands,
404    },
405
406    /// Manage custom command aliases
407    Alias {
408        #[command(subcommand)]
409        command: AliasCommands,
410    },
411
412    /// Time tracking for tickets
413    Time {
414        #[command(subcommand)]
415        command: TimeCommands,
416    },
417
418    /// Manage custom hooks for ticket events
419    Hook {
420        #[command(subcommand)]
421        command: HookCommands,
422    },
423
424    /// Interactive ticket selection (fzf-style)
425    #[command(alias = "i")]
426    Interactive {
427        #[command(subcommand)]
428        command: InteractiveCommands,
429    },
430}
431
432#[derive(Subcommand, Debug)]
433pub enum InteractiveCommands {
434    /// Select and act on a single ticket
435    Select {
436        /// Filter by status
437        #[arg(short, long)]
438        status: Option<String>,
439
440        /// Filter by priority
441        #[arg(short, long)]
442        priority: Option<String>,
443
444        /// Action to perform (show, start, edit, close)
445        #[arg(short, long)]
446        action: Option<String>,
447    },
448
449    /// Select multiple tickets for bulk operations
450    Multi {
451        /// Filter by status
452        #[arg(short, long)]
453        status: Option<String>,
454
455        /// Filter by priority
456        #[arg(short, long)]
457        priority: Option<String>,
458
459        /// Bulk action (close, tag, status)
460        #[arg(short, long, default_value = "close")]
461        action: String,
462    },
463
464    /// Interactively change ticket status
465    Status {
466        /// Ticket ID or slug (optional, will prompt if not provided)
467        ticket: Option<String>,
468    },
469
470    /// Interactively change ticket priority
471    Priority {
472        /// Ticket ID or slug (optional, will prompt if not provided)
473        ticket: Option<String>,
474    },
475}
476
477#[derive(Subcommand, Debug)]
478pub enum ConfigCommands {
479    /// Show current configuration
480    Show {
481        /// Show specific key
482        key: Option<String>,
483    },
484
485    /// Set configuration value
486    Set {
487        /// Configuration key (e.g., project.name, ui.emoji)
488        key: String,
489
490        /// Value to set
491        value: String,
492    },
493
494    /// Get configuration value
495    Get {
496        /// Configuration key
497        key: String,
498    },
499
500    /// Reset configuration to defaults
501    Reset {
502        /// Confirm reset
503        #[arg(long)]
504        force: bool,
505    },
506
507    /// Generate or update CLAUDE.md for AI assistance
508    Claude {
509        /// Append to existing CLAUDE.md instead of overwriting
510        #[arg(short, long)]
511        append: bool,
512
513        /// Template to use (basic, advanced)
514        #[arg(short, long, default_value = "basic")]
515        template: String,
516
517        /// Output path for CLAUDE.md (defaults to project root)
518        #[arg(short, long)]
519        output: Option<String>,
520    },
521}
522
523#[derive(Subcommand, Debug)]
524pub enum TaskCommands {
525    /// Add a new task to a ticket
526    Add {
527        /// Task title
528        title: String,
529
530        /// Ticket ID or slug (defaults to active ticket)
531        #[arg(short, long)]
532        ticket: Option<String>,
533    },
534
535    /// Complete a task
536    Complete {
537        /// Task ID
538        task: String,
539
540        /// Ticket ID or slug (defaults to active ticket)
541        #[arg(short, long)]
542        ticket: Option<String>,
543    },
544
545    /// Uncomplete a task
546    Uncomplete {
547        /// Task ID
548        task: String,
549
550        /// Ticket ID or slug (defaults to active ticket)
551        #[arg(short, long)]
552        ticket: Option<String>,
553    },
554
555    /// List tasks in a ticket
556    List {
557        /// Ticket ID or slug (defaults to active ticket)
558        #[arg(short, long)]
559        ticket: Option<String>,
560
561        /// Show completed tasks only
562        #[arg(long)]
563        completed: bool,
564
565        /// Show incomplete tasks only
566        #[arg(long)]
567        incomplete: bool,
568    },
569
570    /// Remove a task
571    Remove {
572        /// Task ID
573        task: String,
574
575        /// Ticket ID or slug (defaults to active ticket)
576        #[arg(short, long)]
577        ticket: Option<String>,
578
579        /// Force removal without confirmation
580        #[arg(short, long)]
581        force: bool,
582    },
583}
584
585#[derive(Subcommand, Debug)]
586pub enum SpecCommands {
587    /// Initialize a new specification
588    Init {
589        /// Specification title
590        title: String,
591
592        /// Specification description
593        #[arg(short, long)]
594        description: Option<String>,
595
596        /// Associated ticket ID
597        #[arg(short, long)]
598        ticket: Option<String>,
599
600        /// Initial tags (comma-separated)
601        #[arg(long)]
602        tags: Option<String>,
603    },
604
605    /// Create a specification from user requirements (spec-driven development)
606    Specify {
607        /// Requirements description in natural language
608        requirements: String,
609
610        /// Associated ticket ID or slug
611        #[arg(short, long)]
612        ticket: Option<String>,
613
614        /// Use interactive mode for refinement
615        #[arg(short, long)]
616        interactive: bool,
617
618        /// Template to use (default: standard)
619        #[arg(long, default_value = "standard")]
620        template: String,
621
622        /// Output directory for specification
623        #[arg(short, long)]
624        output: Option<String>,
625    },
626
627    /// Create implementation plan from specification
628    Plan {
629        /// Specification ID or path (defaults to active spec)
630        #[arg(short, long)]
631        spec: Option<String>,
632
633        /// Technology stack (comma-separated, e.g., "rust,tokio,sqlx")
634        #[arg(long)]
635        tech_stack: Option<String>,
636
637        /// Architecture pattern (e.g., "mvc", "hexagonal", "layered")
638        #[arg(long)]
639        architecture: Option<String>,
640
641        /// Open in editor for refinement
642        #[arg(short, long)]
643        editor: bool,
644
645        /// Output directory for plan
646        #[arg(short, long)]
647        output: Option<String>,
648    },
649
650    /// Generate executable tasks from plan
651    Tasks {
652        /// Specification ID or path (defaults to active spec)
653        #[arg(short, long)]
654        spec: Option<String>,
655
656        /// Plan file path (defaults to spec's plan)
657        #[arg(long)]
658        plan: Option<String>,
659
660        /// Open in editor
661        #[arg(short, long)]
662        editor: bool,
663
664        /// Mark as complete
665        #[arg(long)]
666        complete: bool,
667
668        /// Export tasks to tickets
669        #[arg(long)]
670        export_tickets: bool,
671
672        /// Generate parallel execution markers
673        #[arg(long)]
674        parallel: bool,
675
676        /// Task granularity (fine, medium, coarse)
677        #[arg(long, default_value = "medium")]
678        granularity: String,
679    },
680
681    /// Validate specification against requirements
682    Validate {
683        /// Specification ID or path
684        #[arg(short, long)]
685        spec: Option<String>,
686
687        /// Check for completeness
688        #[arg(long)]
689        complete: bool,
690
691        /// Check for ambiguities
692        #[arg(long)]
693        ambiguities: bool,
694
695        /// Generate validation report
696        #[arg(long)]
697        report: bool,
698    },
699
700    /// Create or update requirements document
701    Requirements {
702        /// Specification ID (defaults to active spec)
703        #[arg(short, long)]
704        spec: Option<String>,
705
706        /// Open in editor
707        #[arg(short, long)]
708        editor: bool,
709
710        /// Mark as complete
711        #[arg(long)]
712        complete: bool,
713    },
714
715    /// Create or update design document
716    Design {
717        /// Specification ID (defaults to active spec)
718        #[arg(short, long)]
719        spec: Option<String>,
720
721        /// Open in editor
722        #[arg(short, long)]
723        editor: bool,
724
725        /// Mark as complete
726        #[arg(long)]
727        complete: bool,
728    },
729
730    /// Show specification status
731    Status {
732        /// Specification ID (defaults to active spec)
733        #[arg(short, long)]
734        spec: Option<String>,
735
736        /// Show detailed progress
737        #[arg(short, long)]
738        detailed: bool,
739
740        /// Show validation status
741        #[arg(long)]
742        validation: bool,
743    },
744
745    /// List all specifications
746    List {
747        /// Filter by status (draft, `in_progress`, completed, approved)
748        #[arg(short, long)]
749        status: Option<String>,
750
751        /// Filter by phase (requirements, design, tasks)
752        #[arg(long)]
753        phase: Option<String>,
754
755        /// Show archived specs
756        #[arg(long)]
757        archived: bool,
758    },
759
760    /// Show specification details
761    Show {
762        /// Specification ID
763        spec: String,
764
765        /// Show all documents
766        #[arg(short, long)]
767        all: bool,
768
769        /// Show in markdown format
770        #[arg(short, long)]
771        markdown: bool,
772    },
773
774    /// Delete a specification
775    Delete {
776        /// Specification ID
777        spec: String,
778
779        /// Force deletion without confirmation
780        #[arg(short, long)]
781        force: bool,
782    },
783
784    /// Approve a specification phase
785    Approve {
786        /// Specification ID
787        spec: String,
788
789        /// Phase to approve (requirements, design, tasks)
790        phase: String,
791
792        /// Approval message
793        #[arg(short, long)]
794        message: Option<String>,
795    },
796
797    /// Set active specification
798    Activate {
799        /// Specification ID
800        spec: String,
801    },
802
803    /// Generate templates for spec-driven development
804    Template {
805        /// Template type (spec, plan, task, all)
806        #[arg(default_value = "all")]
807        template_type: String,
808
809        /// Output directory
810        #[arg(short, long, default_value = "templates")]
811        output: String,
812
813        /// Force overwrite existing templates
814        #[arg(short, long)]
815        force: bool,
816    },
817}
818
819#[cfg(feature = "mcp")]
820#[derive(Subcommand, Debug)]
821pub enum McpCommands {
822    /// Start MCP server
823    Serve {
824        /// Host to bind to
825        #[arg(short = 'H', long, default_value = "127.0.0.1")]
826        host: Option<String>,
827
828        /// Port to listen on  
829        #[arg(short = 'P', long, default_value = "3033")]
830        port: Option<u16>,
831
832        /// Run as daemon
833        #[arg(short, long)]
834        daemon: bool,
835    },
836}
837
838#[derive(Subcommand, Debug)]
839pub enum WorktreeCommands {
840    /// List all worktrees for vibe-ticket
841    List {
842        /// Show worktrees for all tickets
843        #[arg(short, long)]
844        all: bool,
845
846        /// Filter by status (active, stale, orphaned)
847        #[arg(short, long)]
848        status: Option<String>,
849
850        /// Show detailed information
851        #[arg(short, long)]
852        verbose: bool,
853    },
854
855    /// Remove a worktree
856    Remove {
857        /// Worktree path or ticket ID/slug
858        worktree: String,
859
860        /// Force removal even if there are uncommitted changes
861        #[arg(short, long)]
862        force: bool,
863
864        /// Keep the branch associated with the worktree
865        #[arg(long)]
866        keep_branch: bool,
867    },
868
869    /// Prune stale worktrees
870    Prune {
871        /// Remove worktrees without confirmation
872        #[arg(short, long)]
873        force: bool,
874
875        /// Dry run - show what would be removed
876        #[arg(short, long)]
877        dry_run: bool,
878
879        /// Remove branches for pruned worktrees
880        #[arg(long)]
881        remove_branches: bool,
882    },
883}
884
885#[derive(Subcommand, Debug)]
886pub enum BulkCommands {
887    /// Update multiple tickets at once
888    Update {
889        /// Filter expression (e.g., "status:todo priority:high")
890        #[arg(short, long)]
891        filter: String,
892
893        /// New status to set
894        #[arg(long)]
895        status: Option<String>,
896
897        /// New priority to set
898        #[arg(long)]
899        priority: Option<String>,
900
901        /// New assignee to set
902        #[arg(long)]
903        assignee: Option<String>,
904
905        /// Dry run - show what would be updated
906        #[arg(short, long)]
907        dry_run: bool,
908    },
909
910    /// Add or remove tags from multiple tickets
911    Tag {
912        /// Filter expression (e.g., "status:doing")
913        #[arg(short, long)]
914        filter: String,
915
916        /// Tags to add (comma-separated)
917        #[arg(long)]
918        add: Option<String>,
919
920        /// Tags to remove (comma-separated)
921        #[arg(long)]
922        remove: Option<String>,
923
924        /// Dry run - show what would be updated
925        #[arg(short, long)]
926        dry_run: bool,
927    },
928
929    /// Close multiple tickets at once
930    Close {
931        /// Filter expression (e.g., "status:review")
932        #[arg(short, long)]
933        filter: String,
934
935        /// Close message
936        #[arg(short, long)]
937        message: Option<String>,
938
939        /// Archive the tickets
940        #[arg(short, long)]
941        archive: bool,
942
943        /// Dry run - show what would be closed
944        #[arg(short, long)]
945        dry_run: bool,
946    },
947
948    /// Archive multiple tickets at once
949    Archive {
950        /// Filter expression
951        #[arg(short, long)]
952        filter: String,
953
954        /// Dry run - show what would be archived
955        #[arg(short, long)]
956        dry_run: bool,
957    },
958}
959
960#[derive(Subcommand, Debug)]
961pub enum FilterCommands {
962    /// Create a new saved filter
963    Create {
964        /// Filter name
965        name: String,
966
967        /// Filter expression (e.g., "status:todo priority:high")
968        expression: String,
969
970        /// Filter description
971        #[arg(short, long)]
972        description: Option<String>,
973    },
974
975    /// List saved filters
976    List,
977
978    /// Show filter details
979    Show {
980        /// Filter name
981        name: String,
982    },
983
984    /// Delete a saved filter
985    Delete {
986        /// Filter name
987        name: String,
988
989        /// Force deletion without confirmation
990        #[arg(short, long)]
991        force: bool,
992    },
993
994    /// Apply a saved filter (alias for `list --filter @name`)
995    Apply {
996        /// Filter name
997        name: String,
998
999        /// Additional filter expression to combine
1000        #[arg(short, long)]
1001        additional: Option<String>,
1002    },
1003}
1004
1005#[derive(Subcommand, Debug)]
1006pub enum AliasCommands {
1007    /// Create a new alias
1008    Create {
1009        /// Alias name
1010        name: String,
1011
1012        /// Command to execute (e.g., "list --status todo --priority high")
1013        command: String,
1014
1015        /// Alias description
1016        #[arg(short, long)]
1017        description: Option<String>,
1018    },
1019
1020    /// List all aliases
1021    List,
1022
1023    /// Delete an alias
1024    Delete {
1025        /// Alias name
1026        name: String,
1027    },
1028
1029    /// Run an alias
1030    Run {
1031        /// Alias name
1032        name: String,
1033
1034        /// Additional arguments to pass
1035        #[arg(trailing_var_arg = true)]
1036        args: Vec<String>,
1037    },
1038}
1039
1040#[derive(Subcommand, Debug)]
1041pub enum TimeCommands {
1042    /// Log time spent on a ticket
1043    Log {
1044        /// Time spent (e.g., "1h30m", "2h", "45m")
1045        time: String,
1046
1047        /// Ticket ID or slug (defaults to active ticket)
1048        #[arg(short, long)]
1049        ticket: Option<String>,
1050
1051        /// Notes about the work done
1052        #[arg(short, long)]
1053        notes: Option<String>,
1054
1055        /// Date of work (defaults to today)
1056        #[arg(short, long)]
1057        date: Option<String>,
1058    },
1059
1060    /// Start a timer for the current ticket
1061    Start {
1062        /// Ticket ID or slug (defaults to active ticket)
1063        #[arg(short, long)]
1064        ticket: Option<String>,
1065
1066        /// Notes about the work
1067        #[arg(short, long)]
1068        notes: Option<String>,
1069    },
1070
1071    /// Stop the current timer and log time
1072    Stop {
1073        /// Notes about the work done
1074        #[arg(short, long)]
1075        notes: Option<String>,
1076    },
1077
1078    /// Show current timer status
1079    Status,
1080
1081    /// Show time report for a ticket
1082    Report {
1083        /// Ticket ID or slug (defaults to active ticket)
1084        #[arg(short, long)]
1085        ticket: Option<String>,
1086
1087        /// Show summary for all tickets
1088        #[arg(short, long)]
1089        all: bool,
1090
1091        /// Date range start (e.g., "2024-11-01", "last week")
1092        #[arg(long)]
1093        since: Option<String>,
1094
1095        /// Date range end
1096        #[arg(long)]
1097        until: Option<String>,
1098    },
1099}
1100
1101#[derive(Subcommand, Debug)]
1102pub enum HookCommands {
1103    /// Create a new hook
1104    Create {
1105        /// Hook name
1106        name: String,
1107
1108        /// Event that triggers the hook
1109        #[arg(short, long)]
1110        event: String,
1111
1112        /// Command to execute
1113        #[arg(short, long)]
1114        command: String,
1115
1116        /// Description of the hook
1117        #[arg(short, long)]
1118        description: Option<String>,
1119
1120        /// Abort operation if hook fails (only for pre-* events)
1121        #[arg(long)]
1122        abort_on_failure: bool,
1123    },
1124
1125    /// List all hooks
1126    List,
1127
1128    /// Delete a hook
1129    Delete {
1130        /// Hook name
1131        name: String,
1132    },
1133
1134    /// Enable a hook
1135    Enable {
1136        /// Hook name
1137        name: String,
1138    },
1139
1140    /// Disable a hook
1141    Disable {
1142        /// Hook name
1143        name: String,
1144    },
1145
1146    /// Test a hook with sample data
1147    Test {
1148        /// Hook name
1149        name: String,
1150    },
1151}
1152
1153#[cfg(test)]
1154mod tests {
1155    use super::*;
1156    use clap::Parser;
1157
1158    /// Test basic CLI structure parsing
1159    #[test]
1160    fn test_cli_parse_basic() {
1161        let cli = Cli::parse_from(["vibe-ticket", "--version"]);
1162        assert!(!cli.verbose);
1163        assert!(!cli.json);
1164        assert!(!cli.no_color);
1165        assert!(cli.project.is_none());
1166    }
1167
1168    /// Test global flags
1169    #[test]
1170    fn test_cli_global_flags() {
1171        let cli = Cli::parse_from([
1172            "vibe-ticket",
1173            "--verbose",
1174            "--json",
1175            "--no-color",
1176            "--project",
1177            "/path/to/project",
1178            "list",
1179        ]);
1180        assert!(cli.verbose);
1181        assert!(cli.json);
1182        assert!(cli.no_color);
1183        assert_eq!(cli.project, Some("/path/to/project".to_string()));
1184    }
1185
1186    /// Test init command parsing
1187    #[test]
1188    fn test_init_command() {
1189        let cli = Cli::parse_from(["vibe-ticket", "init"]);
1190        match cli.command {
1191            Commands::Init {
1192                name,
1193                description,
1194                force,
1195                claude_md,
1196            } => {
1197                assert!(name.is_none());
1198                assert!(description.is_none());
1199                assert!(!force);
1200                assert!(!claude_md);
1201            },
1202            _ => panic!("Expected Init command"),
1203        }
1204
1205        let cli = Cli::parse_from([
1206            "vibe-ticket",
1207            "init",
1208            "--name",
1209            "test-project",
1210            "--description",
1211            "Test description",
1212            "--force",
1213            "--claude-md",
1214        ]);
1215        match cli.command {
1216            Commands::Init {
1217                name,
1218                description,
1219                force,
1220                claude_md,
1221            } => {
1222                assert_eq!(name, Some("test-project".to_string()));
1223                assert_eq!(description, Some("Test description".to_string()));
1224                assert!(force);
1225                assert!(claude_md);
1226            },
1227            _ => panic!("Expected Init command"),
1228        }
1229    }
1230
1231    /// Test new command parsing
1232    #[test]
1233    fn test_new_command() {
1234        let cli = Cli::parse_from(["vibe-ticket", "new", "fix-bug"]);
1235        match cli.command {
1236            Commands::New {
1237                slug,
1238                title,
1239                description,
1240                priority,
1241                tags,
1242                start,
1243            } => {
1244                assert_eq!(slug, "fix-bug");
1245                assert!(title.is_none());
1246                assert!(description.is_none());
1247                assert_eq!(priority, "medium");
1248                assert!(tags.is_none());
1249                assert!(!start);
1250            },
1251            _ => panic!("Expected New command"),
1252        }
1253
1254        let cli = Cli::parse_from([
1255            "vibe-ticket",
1256            "new",
1257            "feature-auth",
1258            "--title",
1259            "Add authentication",
1260            "--priority",
1261            "high",
1262            "--tags",
1263            "auth,security",
1264            "--start",
1265        ]);
1266        match cli.command {
1267            Commands::New {
1268                slug,
1269                title,
1270                priority,
1271                tags,
1272                start,
1273                ..
1274            } => {
1275                assert_eq!(slug, "feature-auth");
1276                assert_eq!(title, Some("Add authentication".to_string()));
1277                assert_eq!(priority, "high");
1278                assert_eq!(tags, Some("auth,security".to_string()));
1279                assert!(start);
1280            },
1281            _ => panic!("Expected New command"),
1282        }
1283    }
1284
1285    /// Test list command with various filters
1286    #[test]
1287    fn test_list_command() {
1288        let cli = Cli::parse_from(["vibe-ticket", "list"]);
1289        match cli.command {
1290            Commands::List {
1291                status,
1292                priority,
1293                assignee,
1294                sort,
1295                reverse,
1296                limit,
1297                archived,
1298                open,
1299                since,
1300                until,
1301                ..
1302            } => {
1303                assert!(status.is_none());
1304                assert!(priority.is_none());
1305                assert!(assignee.is_none());
1306                assert_eq!(sort, "slug");
1307                assert!(!reverse);
1308                assert!(limit.is_none());
1309                assert!(!archived);
1310                assert!(!open);
1311                assert!(since.is_none());
1312                assert!(until.is_none());
1313            },
1314            _ => panic!("Expected List command"),
1315        }
1316
1317        let cli = Cli::parse_from([
1318            "vibe-ticket",
1319            "list",
1320            "--status",
1321            "doing",
1322            "--priority",
1323            "high",
1324            "--sort",
1325            "created",
1326            "--reverse",
1327            "--limit",
1328            "10",
1329            "--open",
1330            "--since",
1331            "yesterday",
1332        ]);
1333        match cli.command {
1334            Commands::List {
1335                status,
1336                priority,
1337                sort,
1338                reverse,
1339                limit,
1340                open,
1341                since,
1342                ..
1343            } => {
1344                assert_eq!(status, Some("doing".to_string()));
1345                assert_eq!(priority, Some("high".to_string()));
1346                assert_eq!(sort, "created");
1347                assert!(reverse);
1348                assert_eq!(limit, Some(10));
1349                assert!(open);
1350                assert_eq!(since, Some("yesterday".to_string()));
1351            },
1352            _ => panic!("Expected List command"),
1353        }
1354    }
1355
1356    /// Test start command with worktree options
1357    #[test]
1358    fn test_start_command() {
1359        let cli = Cli::parse_from(["vibe-ticket", "start", "ticket-123"]);
1360        match cli.command {
1361            Commands::Start {
1362                ticket,
1363                branch,
1364                branch_name,
1365                worktree,
1366                no_worktree,
1367            } => {
1368                assert_eq!(ticket, "ticket-123");
1369                assert!(branch);
1370                assert!(branch_name.is_none());
1371                assert!(worktree);
1372                assert!(!no_worktree);
1373            },
1374            _ => panic!("Expected Start command"),
1375        }
1376
1377        let cli = Cli::parse_from([
1378            "vibe-ticket",
1379            "start",
1380            "feature-xyz",
1381            "--no-worktree",
1382            "--branch-name",
1383            "custom-branch",
1384        ]);
1385        match cli.command {
1386            Commands::Start {
1387                ticket,
1388                branch_name,
1389                no_worktree,
1390                ..
1391            } => {
1392                assert_eq!(ticket, "feature-xyz");
1393                assert_eq!(branch_name, Some("custom-branch".to_string()));
1394                assert!(no_worktree);
1395            },
1396            _ => panic!("Expected Start command"),
1397        }
1398    }
1399
1400    /// Test task subcommands
1401    #[test]
1402    fn test_task_commands() {
1403        let cli = Cli::parse_from(["vibe-ticket", "task", "add", "Write tests"]);
1404        match cli.command {
1405            Commands::Task { command } => match command {
1406                TaskCommands::Add { title, ticket } => {
1407                    assert_eq!(title, "Write tests");
1408                    assert!(ticket.is_none());
1409                },
1410                _ => panic!("Expected Task Add command"),
1411            },
1412            _ => panic!("Expected Task command"),
1413        }
1414
1415        let cli = Cli::parse_from([
1416            "vibe-ticket",
1417            "task",
1418            "complete",
1419            "1",
1420            "--ticket",
1421            "fix-bug",
1422        ]);
1423        match cli.command {
1424            Commands::Task { command } => match command {
1425                TaskCommands::Complete { task, ticket } => {
1426                    assert_eq!(task, "1");
1427                    assert_eq!(ticket, Some("fix-bug".to_string()));
1428                },
1429                _ => panic!("Expected Task Complete command"),
1430            },
1431            _ => panic!("Expected Task command"),
1432        }
1433
1434        let cli = Cli::parse_from(["vibe-ticket", "task", "list", "--completed"]);
1435        match cli.command {
1436            Commands::Task { command } => match command {
1437                TaskCommands::List {
1438                    ticket,
1439                    completed,
1440                    incomplete,
1441                } => {
1442                    assert!(ticket.is_none());
1443                    assert!(completed);
1444                    assert!(!incomplete);
1445                },
1446                _ => panic!("Expected Task List command"),
1447            },
1448            _ => panic!("Expected Task command"),
1449        }
1450    }
1451
1452    /// Test config subcommands
1453    #[test]
1454    fn test_config_commands() {
1455        let cli = Cli::parse_from(["vibe-ticket", "config", "show"]);
1456        match cli.command {
1457            Commands::Config { command } => match command {
1458                ConfigCommands::Show { key } => {
1459                    assert!(key.is_none());
1460                },
1461                _ => panic!("Expected Config Show command"),
1462            },
1463            _ => panic!("Expected Config command"),
1464        }
1465
1466        let cli = Cli::parse_from(["vibe-ticket", "config", "set", "ui.emoji", "true"]);
1467        match cli.command {
1468            Commands::Config { command } => match command {
1469                ConfigCommands::Set { key, value } => {
1470                    assert_eq!(key, "ui.emoji");
1471                    assert_eq!(value, "true");
1472                },
1473                _ => panic!("Expected Config Set command"),
1474            },
1475            _ => panic!("Expected Config command"),
1476        }
1477
1478        let cli = Cli::parse_from([
1479            "vibe-ticket",
1480            "config",
1481            "claude",
1482            "--append",
1483            "--template",
1484            "advanced",
1485        ]);
1486        match cli.command {
1487            Commands::Config { command } => match command {
1488                ConfigCommands::Claude {
1489                    append,
1490                    template,
1491                    output,
1492                } => {
1493                    assert!(append);
1494                    assert_eq!(template, "advanced");
1495                    assert!(output.is_none());
1496                },
1497                _ => panic!("Expected Config Claude command"),
1498            },
1499            _ => panic!("Expected Config command"),
1500        }
1501    }
1502
1503    /// Test spec subcommands
1504    #[test]
1505    fn test_spec_commands() {
1506        let cli = Cli::parse_from(["vibe-ticket", "spec", "init", "New Feature Spec"]);
1507        match cli.command {
1508            Commands::Spec { command } => match command {
1509                SpecCommands::Init {
1510                    title,
1511                    description,
1512                    ticket,
1513                    tags,
1514                } => {
1515                    assert_eq!(title, "New Feature Spec");
1516                    assert!(description.is_none());
1517                    assert!(ticket.is_none());
1518                    assert!(tags.is_none());
1519                },
1520                _ => panic!("Expected Spec Init command"),
1521            },
1522            _ => panic!("Expected Spec command"),
1523        }
1524
1525        let cli = Cli::parse_from([
1526            "vibe-ticket",
1527            "spec",
1528            "requirements",
1529            "--editor",
1530            "--complete",
1531        ]);
1532        match cli.command {
1533            Commands::Spec { command } => match command {
1534                SpecCommands::Requirements {
1535                    spec,
1536                    editor,
1537                    complete,
1538                } => {
1539                    assert!(spec.is_none());
1540                    assert!(editor);
1541                    assert!(complete);
1542                },
1543                _ => panic!("Expected Spec Requirements command"),
1544            },
1545            _ => panic!("Expected Spec command"),
1546        }
1547    }
1548
1549    /// Test worktree subcommands
1550    #[test]
1551    fn test_worktree_commands() {
1552        let cli = Cli::parse_from(["vibe-ticket", "worktree", "list", "--all", "--verbose"]);
1553        match cli.command {
1554            Commands::Worktree { command } => match command {
1555                WorktreeCommands::List {
1556                    all,
1557                    status,
1558                    verbose,
1559                } => {
1560                    assert!(all);
1561                    assert!(status.is_none());
1562                    assert!(verbose);
1563                },
1564                _ => panic!("Expected Worktree List command"),
1565            },
1566            _ => panic!("Expected Worktree command"),
1567        }
1568
1569        let cli = Cli::parse_from([
1570            "vibe-ticket",
1571            "worktree",
1572            "remove",
1573            "fix-bug",
1574            "--force",
1575            "--keep-branch",
1576        ]);
1577        match cli.command {
1578            Commands::Worktree { command } => match command {
1579                WorktreeCommands::Remove {
1580                    worktree,
1581                    force,
1582                    keep_branch,
1583                } => {
1584                    assert_eq!(worktree, "fix-bug");
1585                    assert!(force);
1586                    assert!(keep_branch);
1587                },
1588                _ => panic!("Expected Worktree Remove command"),
1589            },
1590            _ => panic!("Expected Worktree command"),
1591        }
1592    }
1593
1594    /// Test edge cases and error scenarios
1595    #[test]
1596    fn test_edge_cases() {
1597        // Test empty tags
1598        let cli = Cli::parse_from(["vibe-ticket", "new", "test", "--tags", ""]);
1599        match cli.command {
1600            Commands::New { tags, .. } => {
1601                assert_eq!(tags, Some(String::new()));
1602            },
1603            _ => panic!("Expected New command"),
1604        }
1605
1606        // Test search with regex
1607        let cli = Cli::parse_from(["vibe-ticket", "search", "bug.*fix", "--regex"]);
1608        match cli.command {
1609            Commands::Search { query, regex, .. } => {
1610                assert_eq!(query, "bug.*fix");
1611                assert!(regex);
1612            },
1613            _ => panic!("Expected Search command"),
1614        }
1615
1616        // Test export with custom output
1617        let cli = Cli::parse_from([
1618            "vibe-ticket",
1619            "export",
1620            "--format",
1621            "yaml",
1622            "--output",
1623            "tickets.yaml",
1624            "--include-archived",
1625        ]);
1626        match cli.command {
1627            Commands::Export {
1628                format,
1629                output,
1630                include_archived,
1631            } => {
1632                assert_eq!(format, "yaml");
1633                assert_eq!(output, Some("tickets.yaml".to_string()));
1634                assert!(include_archived);
1635            },
1636            _ => panic!("Expected Export command"),
1637        }
1638    }
1639
1640    /// Test command aliases
1641    #[test]
1642    fn test_command_aliases() {
1643        // Test claude-md alias
1644        let cli = Cli::parse_from(["vibe-ticket", "init", "--claude"]);
1645        match cli.command {
1646            Commands::Init { claude_md, .. } => {
1647                assert!(claude_md);
1648            },
1649            _ => panic!("Expected Init command"),
1650        }
1651    }
1652
1653    /// Test complex command combinations
1654    #[test]
1655    fn test_complex_commands() {
1656        // Test close with all options
1657        let cli = Cli::parse_from([
1658            "vibe-ticket",
1659            "close",
1660            "feature-123",
1661            "--message",
1662            "Completed feature",
1663            "--archive",
1664            "--pr",
1665        ]);
1666        match cli.command {
1667            Commands::Close {
1668                ticket,
1669                message,
1670                archive,
1671                pr,
1672            } => {
1673                assert_eq!(ticket, Some("feature-123".to_string()));
1674                assert_eq!(message, Some("Completed feature".to_string()));
1675                assert!(archive);
1676                assert!(pr);
1677            },
1678            _ => panic!("Expected Close command"),
1679        }
1680
1681        // Test edit with multiple tag operations
1682        let cli = Cli::parse_from([
1683            "vibe-ticket",
1684            "edit",
1685            "--title",
1686            "New Title",
1687            "--add-tags",
1688            "urgent,frontend",
1689            "--remove-tags",
1690            "backend",
1691            "--status",
1692            "review",
1693        ]);
1694        match cli.command {
1695            Commands::Edit {
1696                ticket,
1697                title,
1698                add_tags,
1699                remove_tags,
1700                status,
1701                ..
1702            } => {
1703                assert!(ticket.is_none());
1704                assert_eq!(title, Some("New Title".to_string()));
1705                assert_eq!(add_tags, Some("urgent,frontend".to_string()));
1706                assert_eq!(remove_tags, Some("backend".to_string()));
1707                assert_eq!(status, Some("review".to_string()));
1708            },
1709            _ => panic!("Expected Edit command"),
1710        }
1711    }
1712
1713    /// Test default values
1714    #[test]
1715    fn test_default_values() {
1716        // Test list sort default
1717        let cli = Cli::parse_from(["vibe-ticket", "list"]);
1718        match cli.command {
1719            Commands::List { sort, .. } => {
1720                assert_eq!(sort, "slug");
1721            },
1722            _ => panic!("Expected List command"),
1723        }
1724
1725        // Test open sort default
1726        let cli = Cli::parse_from(["vibe-ticket", "open"]);
1727        match cli.command {
1728            Commands::Open { sort, .. } => {
1729                assert_eq!(sort, "updated");
1730            },
1731            _ => panic!("Expected Open command"),
1732        }
1733
1734        // Test export format default
1735        let cli = Cli::parse_from(["vibe-ticket", "export"]);
1736        match cli.command {
1737            Commands::Export { format, .. } => {
1738                assert_eq!(format, "json");
1739            },
1740            _ => panic!("Expected Export command"),
1741        }
1742    }
1743
1744    /// Test import command variations
1745    #[test]
1746    fn test_import_command() {
1747        let cli = Cli::parse_from(["vibe-ticket", "import", "data.json"]);
1748        match cli.command {
1749            Commands::Import {
1750                file,
1751                format,
1752                skip_validation,
1753                dry_run,
1754            } => {
1755                assert_eq!(file, "data.json");
1756                assert!(format.is_none());
1757                assert!(!skip_validation);
1758                assert!(!dry_run);
1759            },
1760            _ => panic!("Expected Import command"),
1761        }
1762
1763        let cli = Cli::parse_from([
1764            "vibe-ticket",
1765            "import",
1766            "tickets.csv",
1767            "--format",
1768            "csv",
1769            "--skip-validation",
1770            "--dry-run",
1771        ]);
1772        match cli.command {
1773            Commands::Import {
1774                file,
1775                format,
1776                skip_validation,
1777                dry_run,
1778            } => {
1779                assert_eq!(file, "tickets.csv");
1780                assert_eq!(format, Some("csv".to_string()));
1781                assert!(skip_validation);
1782                assert!(dry_run);
1783            },
1784            _ => panic!("Expected Import command"),
1785        }
1786    }
1787
1788    /// Test show command variations
1789    #[test]
1790    fn test_show_command() {
1791        let cli = Cli::parse_from(["vibe-ticket", "show", "ABC-123"]);
1792        match cli.command {
1793            Commands::Show {
1794                ticket,
1795                tasks,
1796                history,
1797                markdown,
1798            } => {
1799                assert_eq!(ticket, "ABC-123");
1800                assert!(!tasks);
1801                assert!(!history);
1802                assert!(!markdown);
1803            },
1804            _ => panic!("Expected Show command"),
1805        }
1806
1807        let cli = Cli::parse_from([
1808            "vibe-ticket",
1809            "show",
1810            "feature-1",
1811            "--tasks",
1812            "--history",
1813            "--markdown",
1814        ]);
1815        match cli.command {
1816            Commands::Show {
1817                ticket,
1818                tasks,
1819                history,
1820                markdown,
1821            } => {
1822                assert_eq!(ticket, "feature-1");
1823                assert!(tasks);
1824                assert!(history);
1825                assert!(markdown);
1826            },
1827            _ => panic!("Expected Show command"),
1828        }
1829    }
1830
1831    /// Test check command variations
1832    #[test]
1833    fn test_check_command() {
1834        let cli = Cli::parse_from(["vibe-ticket", "check"]);
1835        match cli.command {
1836            Commands::Check { detailed, stats } => {
1837                assert!(!detailed);
1838                assert!(!stats);
1839            },
1840            _ => panic!("Expected Check command"),
1841        }
1842
1843        let cli = Cli::parse_from(["vibe-ticket", "check", "--detailed", "--stats"]);
1844        match cli.command {
1845            Commands::Check { detailed, stats } => {
1846                assert!(detailed);
1847                assert!(stats);
1848            },
1849            _ => panic!("Expected Check command"),
1850        }
1851    }
1852
1853    /// Test archive command
1854    #[test]
1855    fn test_archive_command() {
1856        let cli = Cli::parse_from(["vibe-ticket", "archive", "old-ticket"]);
1857        match cli.command {
1858            Commands::Archive { ticket, unarchive } => {
1859                assert_eq!(ticket, "old-ticket");
1860                assert!(!unarchive);
1861            },
1862            _ => panic!("Expected Archive command"),
1863        }
1864
1865        let cli = Cli::parse_from(["vibe-ticket", "archive", "ticket-123", "--unarchive"]);
1866        match cli.command {
1867            Commands::Archive { ticket, unarchive } => {
1868                assert_eq!(ticket, "ticket-123");
1869                assert!(unarchive);
1870            },
1871            _ => panic!("Expected Archive command"),
1872        }
1873    }
1874
1875    /// Test search command filters
1876    #[test]
1877    fn test_search_filters() {
1878        let cli = Cli::parse_from(["vibe-ticket", "search", "auth", "--title"]);
1879        match cli.command {
1880            Commands::Search {
1881                query,
1882                title,
1883                description,
1884                tags,
1885                ..
1886            } => {
1887                assert_eq!(query, "auth");
1888                assert!(title);
1889                assert!(!description);
1890                assert!(!tags);
1891            },
1892            _ => panic!("Expected Search command"),
1893        }
1894
1895        let cli = Cli::parse_from([
1896            "vibe-ticket",
1897            "search",
1898            "security",
1899            "--description",
1900            "--tags",
1901        ]);
1902        match cli.command {
1903            Commands::Search {
1904                query,
1905                title,
1906                description,
1907                tags,
1908                ..
1909            } => {
1910                assert_eq!(query, "security");
1911                assert!(!title);
1912                assert!(description);
1913                assert!(tags);
1914            },
1915            _ => panic!("Expected Search command"),
1916        }
1917    }
1918
1919    /// Test spec command variations
1920    #[test]
1921    fn test_spec_variations() {
1922        let cli = Cli::parse_from([
1923            "vibe-ticket",
1924            "spec",
1925            "list",
1926            "--status",
1927            "draft",
1928            "--phase",
1929            "requirements",
1930            "--archived",
1931        ]);
1932        match cli.command {
1933            Commands::Spec { command } => match command {
1934                SpecCommands::List {
1935                    status,
1936                    phase,
1937                    archived,
1938                } => {
1939                    assert_eq!(status, Some("draft".to_string()));
1940                    assert_eq!(phase, Some("requirements".to_string()));
1941                    assert!(archived);
1942                },
1943                _ => panic!("Expected Spec List command"),
1944            },
1945            _ => panic!("Expected Spec command"),
1946        }
1947
1948        let cli = Cli::parse_from([
1949            "vibe-ticket",
1950            "spec",
1951            "approve",
1952            "spec-123",
1953            "design",
1954            "--message",
1955            "LGTM",
1956        ]);
1957        match cli.command {
1958            Commands::Spec { command } => match command {
1959                SpecCommands::Approve {
1960                    spec,
1961                    phase,
1962                    message,
1963                } => {
1964                    assert_eq!(spec, "spec-123");
1965                    assert_eq!(phase, "design");
1966                    assert_eq!(message, Some("LGTM".to_string()));
1967                },
1968                _ => panic!("Expected Spec Approve command"),
1969            },
1970            _ => panic!("Expected Spec command"),
1971        }
1972    }
1973
1974    /// Test worktree prune options
1975    #[test]
1976    fn test_worktree_prune() {
1977        let cli = Cli::parse_from(["vibe-ticket", "worktree", "prune"]);
1978        match cli.command {
1979            Commands::Worktree { command } => match command {
1980                WorktreeCommands::Prune {
1981                    force,
1982                    dry_run,
1983                    remove_branches,
1984                } => {
1985                    assert!(!force);
1986                    assert!(!dry_run);
1987                    assert!(!remove_branches);
1988                },
1989                _ => panic!("Expected Worktree Prune command"),
1990            },
1991            _ => panic!("Expected Worktree command"),
1992        }
1993
1994        let cli = Cli::parse_from([
1995            "vibe-ticket",
1996            "worktree",
1997            "prune",
1998            "--force",
1999            "--dry-run",
2000            "--remove-branches",
2001        ]);
2002        match cli.command {
2003            Commands::Worktree { command } => match command {
2004                WorktreeCommands::Prune {
2005                    force,
2006                    dry_run,
2007                    remove_branches,
2008                } => {
2009                    assert!(force);
2010                    assert!(dry_run);
2011                    assert!(remove_branches);
2012                },
2013                _ => panic!("Expected Worktree Prune command"),
2014            },
2015            _ => panic!("Expected Worktree command"),
2016        }
2017    }
2018}