1use clap::{Parser, Subcommand};
2
3#[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 #[arg(short, long, global = true)]
11 pub verbose: bool,
12
13 #[arg(short, long, global = true)]
15 pub json: bool,
16
17 #[arg(long, global = true)]
19 pub no_color: bool,
20
21 #[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 Init {
33 #[arg(short, long)]
35 name: Option<String>,
36
37 #[arg(short, long)]
39 description: Option<String>,
40
41 #[arg(short, long)]
43 force: bool,
44
45 #[arg(long = "claude-md", alias = "claude")]
47 claude_md: bool,
48 },
49
50 New {
52 slug: String,
54
55 #[arg(short, long)]
57 title: Option<String>,
58
59 #[arg(short, long)]
61 description: Option<String>,
62
63 #[arg(long, default_value = "medium")]
65 priority: String,
66
67 #[arg(long)]
69 tags: Option<String>,
70
71 #[arg(short, long)]
73 start: bool,
74 },
75
76 List {
78 #[arg(short, long)]
80 status: Option<String>,
81
82 #[arg(long)]
84 priority: Option<String>,
85
86 #[arg(short, long)]
88 assignee: Option<String>,
89
90 #[arg(long, default_value = "slug")]
92 sort: String,
93
94 #[arg(short, long)]
96 reverse: bool,
97
98 #[arg(short, long)]
100 limit: Option<usize>,
101
102 #[arg(long)]
104 archived: bool,
105
106 #[arg(long)]
108 open: bool,
109
110 #[arg(long)]
112 since: Option<String>,
113
114 #[arg(long)]
116 until: Option<String>,
117
118 #[arg(long)]
120 include_done: bool,
121 },
122
123 Board {
125 #[arg(short, long)]
127 assignee: Option<String>,
128
129 #[arg(long)]
131 active_only: bool,
132
133 #[arg(short, long)]
135 compact: bool,
136 },
137
138 Start {
140 ticket: String,
142
143 #[arg(short, long, default_value = "true")]
145 branch: bool,
146
147 #[arg(long)]
149 branch_name: Option<String>,
150
151 #[arg(long, default_value = "true")]
153 worktree: bool,
154
155 #[arg(long = "no-worktree", conflicts_with = "worktree")]
157 no_worktree: bool,
158 },
159
160 Open {
162 #[arg(long, default_value = "updated")]
164 sort: String,
165
166 #[arg(short, long)]
168 reverse: bool,
169
170 #[arg(short, long)]
172 limit: Option<usize>,
173 },
174
175 Close {
177 ticket: Option<String>,
179
180 #[arg(short, long)]
182 message: Option<String>,
183
184 #[arg(short, long)]
186 archive: bool,
187
188 #[arg(long)]
190 pr: bool,
191 },
192
193 Review {
195 ticket: Option<String>,
197
198 #[arg(short, long)]
200 notes: Option<String>,
201 },
202
203 Approve {
205 ticket: Option<String>,
207
208 #[arg(short, long)]
210 message: Option<String>,
211 },
212
213 RequestChanges {
215 ticket: Option<String>,
217
218 #[arg(short, long)]
220 changes: String,
221 },
222
223 Handoff {
225 ticket: Option<String>,
227
228 assignee: String,
230
231 #[arg(short, long)]
233 notes: Option<String>,
234 },
235
236 Check {
238 #[arg(short, long)]
240 detailed: bool,
241
242 #[arg(short, long)]
244 stats: bool,
245 },
246
247 Edit {
249 ticket: Option<String>,
251
252 #[arg(long)]
254 title: Option<String>,
255
256 #[arg(long)]
258 description: Option<String>,
259
260 #[arg(long)]
262 priority: Option<String>,
263
264 #[arg(long)]
266 status: Option<String>,
267
268 #[arg(long)]
270 add_tags: Option<String>,
271
272 #[arg(long)]
274 remove_tags: Option<String>,
275
276 #[arg(short, long)]
278 editor: bool,
279 },
280
281 Show {
283 ticket: String,
285
286 #[arg(short, long)]
288 tasks: bool,
289
290 #[arg(long)]
292 history: bool,
293
294 #[arg(short, long)]
296 markdown: bool,
297 },
298
299 Task {
301 #[command(subcommand)]
302 command: TaskCommands,
303 },
304
305 Archive {
307 ticket: String,
309
310 #[arg(short, long)]
312 unarchive: bool,
313 },
314
315 Search {
317 query: String,
319
320 #[arg(long)]
322 title: bool,
323
324 #[arg(long)]
326 description: bool,
327
328 #[arg(long)]
330 tags: bool,
331
332 #[arg(short, long)]
334 regex: bool,
335 },
336
337 Export {
339 #[arg(short, long, default_value = "json")]
341 format: String,
342
343 #[arg(short, long)]
345 output: Option<String>,
346
347 #[arg(long)]
349 include_archived: bool,
350 },
351
352 Import {
354 file: String,
356
357 #[arg(short, long)]
359 format: Option<String>,
360
361 #[arg(long)]
363 skip_validation: bool,
364
365 #[arg(long)]
367 dry_run: bool,
368 },
369
370 Config {
372 #[command(subcommand)]
373 command: ConfigCommands,
374 },
375
376 Spec {
378 #[command(subcommand)]
379 command: SpecCommands,
380 },
381 Worktree {
383 #[command(subcommand)]
384 command: WorktreeCommands,
385 },
386
387 #[cfg(feature = "mcp")]
389 Mcp {
390 #[command(subcommand)]
391 command: McpCommands,
392 },
393
394 Bulk {
396 #[command(subcommand)]
397 command: BulkCommands,
398 },
399
400 Filter {
402 #[command(subcommand)]
403 command: FilterCommands,
404 },
405
406 Alias {
408 #[command(subcommand)]
409 command: AliasCommands,
410 },
411
412 Time {
414 #[command(subcommand)]
415 command: TimeCommands,
416 },
417
418 Hook {
420 #[command(subcommand)]
421 command: HookCommands,
422 },
423
424 #[command(alias = "i")]
426 Interactive {
427 #[command(subcommand)]
428 command: InteractiveCommands,
429 },
430}
431
432#[derive(Subcommand, Debug)]
433pub enum InteractiveCommands {
434 Select {
436 #[arg(short, long)]
438 status: Option<String>,
439
440 #[arg(short, long)]
442 priority: Option<String>,
443
444 #[arg(short, long)]
446 action: Option<String>,
447 },
448
449 Multi {
451 #[arg(short, long)]
453 status: Option<String>,
454
455 #[arg(short, long)]
457 priority: Option<String>,
458
459 #[arg(short, long, default_value = "close")]
461 action: String,
462 },
463
464 Status {
466 ticket: Option<String>,
468 },
469
470 Priority {
472 ticket: Option<String>,
474 },
475}
476
477#[derive(Subcommand, Debug)]
478pub enum ConfigCommands {
479 Show {
481 key: Option<String>,
483 },
484
485 Set {
487 key: String,
489
490 value: String,
492 },
493
494 Get {
496 key: String,
498 },
499
500 Reset {
502 #[arg(long)]
504 force: bool,
505 },
506
507 Claude {
509 #[arg(short, long)]
511 append: bool,
512
513 #[arg(short, long, default_value = "basic")]
515 template: String,
516
517 #[arg(short, long)]
519 output: Option<String>,
520 },
521}
522
523#[derive(Subcommand, Debug)]
524pub enum TaskCommands {
525 Add {
527 title: String,
529
530 #[arg(short, long)]
532 ticket: Option<String>,
533 },
534
535 Complete {
537 task: String,
539
540 #[arg(short, long)]
542 ticket: Option<String>,
543 },
544
545 Uncomplete {
547 task: String,
549
550 #[arg(short, long)]
552 ticket: Option<String>,
553 },
554
555 List {
557 #[arg(short, long)]
559 ticket: Option<String>,
560
561 #[arg(long)]
563 completed: bool,
564
565 #[arg(long)]
567 incomplete: bool,
568 },
569
570 Remove {
572 task: String,
574
575 #[arg(short, long)]
577 ticket: Option<String>,
578
579 #[arg(short, long)]
581 force: bool,
582 },
583}
584
585#[derive(Subcommand, Debug)]
586pub enum SpecCommands {
587 Init {
589 title: String,
591
592 #[arg(short, long)]
594 description: Option<String>,
595
596 #[arg(short, long)]
598 ticket: Option<String>,
599
600 #[arg(long)]
602 tags: Option<String>,
603 },
604
605 Specify {
607 requirements: String,
609
610 #[arg(short, long)]
612 ticket: Option<String>,
613
614 #[arg(short, long)]
616 interactive: bool,
617
618 #[arg(long, default_value = "standard")]
620 template: String,
621
622 #[arg(short, long)]
624 output: Option<String>,
625 },
626
627 Plan {
629 #[arg(short, long)]
631 spec: Option<String>,
632
633 #[arg(long)]
635 tech_stack: Option<String>,
636
637 #[arg(long)]
639 architecture: Option<String>,
640
641 #[arg(short, long)]
643 editor: bool,
644
645 #[arg(short, long)]
647 output: Option<String>,
648 },
649
650 Tasks {
652 #[arg(short, long)]
654 spec: Option<String>,
655
656 #[arg(long)]
658 plan: Option<String>,
659
660 #[arg(short, long)]
662 editor: bool,
663
664 #[arg(long)]
666 complete: bool,
667
668 #[arg(long)]
670 export_tickets: bool,
671
672 #[arg(long)]
674 parallel: bool,
675
676 #[arg(long, default_value = "medium")]
678 granularity: String,
679 },
680
681 Validate {
683 #[arg(short, long)]
685 spec: Option<String>,
686
687 #[arg(long)]
689 complete: bool,
690
691 #[arg(long)]
693 ambiguities: bool,
694
695 #[arg(long)]
697 report: bool,
698 },
699
700 Requirements {
702 #[arg(short, long)]
704 spec: Option<String>,
705
706 #[arg(short, long)]
708 editor: bool,
709
710 #[arg(long)]
712 complete: bool,
713 },
714
715 Design {
717 #[arg(short, long)]
719 spec: Option<String>,
720
721 #[arg(short, long)]
723 editor: bool,
724
725 #[arg(long)]
727 complete: bool,
728 },
729
730 Status {
732 #[arg(short, long)]
734 spec: Option<String>,
735
736 #[arg(short, long)]
738 detailed: bool,
739
740 #[arg(long)]
742 validation: bool,
743 },
744
745 List {
747 #[arg(short, long)]
749 status: Option<String>,
750
751 #[arg(long)]
753 phase: Option<String>,
754
755 #[arg(long)]
757 archived: bool,
758 },
759
760 Show {
762 spec: String,
764
765 #[arg(short, long)]
767 all: bool,
768
769 #[arg(short, long)]
771 markdown: bool,
772 },
773
774 Delete {
776 spec: String,
778
779 #[arg(short, long)]
781 force: bool,
782 },
783
784 Approve {
786 spec: String,
788
789 phase: String,
791
792 #[arg(short, long)]
794 message: Option<String>,
795 },
796
797 Activate {
799 spec: String,
801 },
802
803 Template {
805 #[arg(default_value = "all")]
807 template_type: String,
808
809 #[arg(short, long, default_value = "templates")]
811 output: String,
812
813 #[arg(short, long)]
815 force: bool,
816 },
817}
818
819#[cfg(feature = "mcp")]
820#[derive(Subcommand, Debug)]
821pub enum McpCommands {
822 Serve {
824 #[arg(short = 'H', long, default_value = "127.0.0.1")]
826 host: Option<String>,
827
828 #[arg(short = 'P', long, default_value = "3033")]
830 port: Option<u16>,
831
832 #[arg(short, long)]
834 daemon: bool,
835 },
836}
837
838#[derive(Subcommand, Debug)]
839pub enum WorktreeCommands {
840 List {
842 #[arg(short, long)]
844 all: bool,
845
846 #[arg(short, long)]
848 status: Option<String>,
849
850 #[arg(short, long)]
852 verbose: bool,
853 },
854
855 Remove {
857 worktree: String,
859
860 #[arg(short, long)]
862 force: bool,
863
864 #[arg(long)]
866 keep_branch: bool,
867 },
868
869 Prune {
871 #[arg(short, long)]
873 force: bool,
874
875 #[arg(short, long)]
877 dry_run: bool,
878
879 #[arg(long)]
881 remove_branches: bool,
882 },
883}
884
885#[derive(Subcommand, Debug)]
886pub enum BulkCommands {
887 Update {
889 #[arg(short, long)]
891 filter: String,
892
893 #[arg(long)]
895 status: Option<String>,
896
897 #[arg(long)]
899 priority: Option<String>,
900
901 #[arg(long)]
903 assignee: Option<String>,
904
905 #[arg(short, long)]
907 dry_run: bool,
908 },
909
910 Tag {
912 #[arg(short, long)]
914 filter: String,
915
916 #[arg(long)]
918 add: Option<String>,
919
920 #[arg(long)]
922 remove: Option<String>,
923
924 #[arg(short, long)]
926 dry_run: bool,
927 },
928
929 Close {
931 #[arg(short, long)]
933 filter: String,
934
935 #[arg(short, long)]
937 message: Option<String>,
938
939 #[arg(short, long)]
941 archive: bool,
942
943 #[arg(short, long)]
945 dry_run: bool,
946 },
947
948 Archive {
950 #[arg(short, long)]
952 filter: String,
953
954 #[arg(short, long)]
956 dry_run: bool,
957 },
958}
959
960#[derive(Subcommand, Debug)]
961pub enum FilterCommands {
962 Create {
964 name: String,
966
967 expression: String,
969
970 #[arg(short, long)]
972 description: Option<String>,
973 },
974
975 List,
977
978 Show {
980 name: String,
982 },
983
984 Delete {
986 name: String,
988
989 #[arg(short, long)]
991 force: bool,
992 },
993
994 Apply {
996 name: String,
998
999 #[arg(short, long)]
1001 additional: Option<String>,
1002 },
1003}
1004
1005#[derive(Subcommand, Debug)]
1006pub enum AliasCommands {
1007 Create {
1009 name: String,
1011
1012 command: String,
1014
1015 #[arg(short, long)]
1017 description: Option<String>,
1018 },
1019
1020 List,
1022
1023 Delete {
1025 name: String,
1027 },
1028
1029 Run {
1031 name: String,
1033
1034 #[arg(trailing_var_arg = true)]
1036 args: Vec<String>,
1037 },
1038}
1039
1040#[derive(Subcommand, Debug)]
1041pub enum TimeCommands {
1042 Log {
1044 time: String,
1046
1047 #[arg(short, long)]
1049 ticket: Option<String>,
1050
1051 #[arg(short, long)]
1053 notes: Option<String>,
1054
1055 #[arg(short, long)]
1057 date: Option<String>,
1058 },
1059
1060 Start {
1062 #[arg(short, long)]
1064 ticket: Option<String>,
1065
1066 #[arg(short, long)]
1068 notes: Option<String>,
1069 },
1070
1071 Stop {
1073 #[arg(short, long)]
1075 notes: Option<String>,
1076 },
1077
1078 Status,
1080
1081 Report {
1083 #[arg(short, long)]
1085 ticket: Option<String>,
1086
1087 #[arg(short, long)]
1089 all: bool,
1090
1091 #[arg(long)]
1093 since: Option<String>,
1094
1095 #[arg(long)]
1097 until: Option<String>,
1098 },
1099}
1100
1101#[derive(Subcommand, Debug)]
1102pub enum HookCommands {
1103 Create {
1105 name: String,
1107
1108 #[arg(short, long)]
1110 event: String,
1111
1112 #[arg(short, long)]
1114 command: String,
1115
1116 #[arg(short, long)]
1118 description: Option<String>,
1119
1120 #[arg(long)]
1122 abort_on_failure: bool,
1123 },
1124
1125 List,
1127
1128 Delete {
1130 name: String,
1132 },
1133
1134 Enable {
1136 name: String,
1138 },
1139
1140 Disable {
1142 name: String,
1144 },
1145
1146 Test {
1148 name: String,
1150 },
1151}
1152
1153#[cfg(test)]
1154mod tests {
1155 use super::*;
1156 use clap::Parser;
1157
1158 #[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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
1596 fn test_edge_cases() {
1597 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 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 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]
1642 fn test_command_aliases() {
1643 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]
1655 fn test_complex_commands() {
1656 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 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]
1715 fn test_default_values() {
1716 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 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 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]
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]
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]
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]
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]
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]
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]
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}