1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
use clap::builder::styling::{AnsiColor, Effects, Styles};
use clap::{Args, Parser, Subcommand};
use std::ffi::OsString;
/// Full version string, uv-style: `0.6.4 (63c5f57d3 2026-05-08 <target>)`.
///
/// Built by `build.rs`; degrades to the bare crate version when git metadata is
/// unavailable. clap prefixes the binary name, so `--version` prints
/// `bougie 0.6.4 (...)`.
pub const LONG_VERSION: &str = env!("BOUGIE_LONG_VERSION");
const HELP_STYLES: Styles = Styles::styled()
.header(AnsiColor::Blue.on_default().effects(Effects::BOLD))
.usage(AnsiColor::Magenta.on_default().effects(Effects::BOLD))
.literal(AnsiColor::BrightMagenta.on_default().effects(Effects::BOLD))
.placeholder(AnsiColor::BrightMagenta.on_default())
.error(AnsiColor::Red.on_default().effects(Effects::BOLD))
.valid(AnsiColor::Green.on_default())
.invalid(AnsiColor::Yellow.on_default().effects(Effects::BOLD));
/// Grouped quick-reference appended to `bougie --help`. clap renders all
/// subcommands in one flat "Commands:" list (it has no headed-group
/// support), and `display_order` clusters that list into these same
/// groups — this cheat-sheet just names the groups so the core verbs are
/// findable at a glance.
const COMMAND_GROUPS: &str = "\
Command groups:
Project init, new, start, stop, run, sync, make, format
Dependencies add, remove, lock, tree, outdated, ext, composer
Toolchain php, node, tool
Services server, services, projects
Admin cache, self
Run `bougie help <command>` for details on any command.";
#[derive(Parser, Debug)]
#[command(
name = "bougie",
version = LONG_VERSION,
about,
long_about = None,
styles = HELP_STYLES,
after_long_help = COMMAND_GROUPS,
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
/// Suppress non-error output.
#[arg(short, long, global = true)]
pub quiet: bool,
/// Verbose output.
#[arg(short, long, global = true)]
pub verbose: bool,
/// Output format.
#[arg(long, global = true, default_value = "text")]
pub format: OutputFormat,
}
/// Shared PHP-source preference flags (uv's system-Python model adapted
/// to PHP). Flattened into `sync` / `run`; `--managed-php` and
/// `--no-managed-php` are mutually exclusive. With none set, bougie's
/// default applies: prefer an installed managed PHP, then a qualifying
/// system PHP, then download a managed one.
#[derive(Args, Debug, Clone, Copy, Default)]
pub struct PhpPrefArgs {
/// Only use a bougie-managed PHP; never a system PHP.
#[arg(long, conflicts_with = "no_managed_php")]
pub managed_php: bool,
/// Only use a system PHP already on this machine; never a managed one.
#[arg(long)]
pub no_managed_php: bool,
/// Never download a managed PHP — use an installed managed PHP or a
/// system one. Errors if neither is present.
#[arg(long)]
pub no_php_downloads: bool,
}
#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
pub enum OutputFormat {
Text,
/// `json-v1` is bougie's structured envelope; `json` is accepted as
/// an alias so Composer-compatible subcommands (`composer show
/// --format json`, etc.) work with the same global flag.
#[value(name = "json-v1", alias = "json")]
JsonV1,
}
#[derive(Subcommand, Debug)]
pub enum Command {
/// Create a new project.
#[command(display_order = 1)]
Init {
/// Place bougie configuration in a bougie.toml file.
#[arg(long)]
toml: bool,
/// Set the package name (`vendor/package`) of the generated
/// composer.json. Overrides the name from a `--starter` manifest.
#[arg(long, value_name = "VENDOR/PACKAGE")]
name: Option<String>,
/// Scaffold from a starter pack: a built-in alias (e.g. `mageos`)
/// or an https URL serving a starter manifest. Writes the
/// starter's composer.json instead of the empty default.
#[arg(long, value_name = "URL_OR_ALIAS")]
starter: Option<String>,
/// After scaffolding, bring the project up — equivalent to
/// `bougie start` (sync the toolchain + vendor, then run the
/// project recipe). Unix-only.
#[arg(long)]
start: bool,
},
/// Create a new project in a new directory.
#[command(display_order = 2)]
New {
/// Directory to create under the current directory and scaffold
/// the project into.
#[arg(value_name = "DIRECTORY")]
directory: String,
/// Place bougie configuration in a bougie.toml file.
#[arg(long)]
toml: bool,
/// Set the package name (`vendor/package`) of the generated
/// composer.json. Overrides the name from a `--starter` manifest.
#[arg(long, value_name = "VENDOR/PACKAGE")]
name: Option<String>,
/// Scaffold from a starter pack: a built-in alias (e.g. `mageos`)
/// or an https URL serving a starter manifest.
#[arg(long, value_name = "URL_OR_ALIAS")]
starter: Option<String>,
/// After scaffolding, bring the project up — equivalent to
/// `bougie start`. Unix-only.
#[arg(long)]
start: bool,
},
/// Manage PHP extensions.
#[command(subcommand, display_order = 15)]
Ext(ExtCommand),
/// Add one or more packages to the project and sync. The uv-flavored
/// twin of `composer require`: a bare `vendor/pkg` writes a `>=X.Y`
/// lower bound (vs `composer require`'s caret `^X.Y`), and an
/// explicit constraint uses the `@` syntax (`vendor/pkg@^1.0`), as in
/// `bougie tool install` / `bougie ext add`. Edits `composer.json`,
/// re-resolves `composer.lock`, and installs into `vendor/`.
#[command(display_order = 10)]
Add {
/// Packages to add, `vendor/pkg` or `vendor/pkg@<constraint>`.
#[arg(value_name = "PACKAGES", required = true)]
packages: Vec<String>,
/// Add to `require-dev` instead of `require`.
#[arg(long = "dev")]
dev: bool,
/// Also update the new packages' dependencies (`-w`).
#[arg(short = 'w', long = "with-dependencies")]
with_dependencies: bool,
/// Also update all dependencies, including shared ones (`-W`).
#[arg(short = 'W', long = "with-all-dependencies")]
with_all_dependencies: bool,
/// Update `composer.json` + `composer.lock` but don't install
/// into `vendor/`.
#[arg(long = "no-sync")]
no_sync: bool,
/// Edit `composer.json` only — don't touch the lock or `vendor/`.
#[arg(long = "frozen")]
frozen: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Resolve and report what would change without writing anything.
#[arg(long = "dry-run")]
dry_run: bool,
},
/// Remove one or more packages from the project and sync. The
/// uv-flavored twin of `composer remove`.
#[command(display_order = 11)]
Remove {
/// Packages to remove (`vendor/name`).
#[arg(value_name = "PACKAGES", required = true)]
packages: Vec<String>,
/// Remove from `require-dev` instead of `require`.
#[arg(long = "dev")]
dev: bool,
/// Re-resolve `composer.lock` but don't touch `vendor/`.
#[arg(long = "no-sync")]
no_sync: bool,
/// Edit `composer.json` only — don't touch the lock or `vendor/`.
#[arg(long = "frozen")]
frozen: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Resolve and report what would change without writing anything.
#[arg(long = "dry-run")]
dry_run: bool,
},
/// Refresh `composer.lock` to match `composer.json` (native; uv's
/// `uv lock`). Minimal: keeps every package at its locked version
/// where still valid, re-resolving only what changed. Never bumps
/// versions and never installs — use `bougie composer update` to pull
/// newer versions.
#[command(display_order = 12)]
Lock {
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Resolve and report what would change without writing the lock.
#[arg(long = "dry-run")]
dry_run: bool,
},
/// Print the project's dependency tree (native; uv's `uv tree`).
/// Reads `composer.lock`.
#[command(display_order = 13)]
Tree {
/// Root the tree at this package instead of the project.
#[arg(value_name = "PACKAGE")]
package: Option<String>,
/// Skip dev dependencies.
#[arg(long = "no-dev")]
no_dev: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// List installed packages with a newer version available (native;
/// like `uv`/`pnpm outdated`). Reads `composer.lock` and queries the
/// configured repositories.
#[command(display_order = 14)]
Outdated {
/// Optional `vendor/name` filters; with none, all are considered.
#[arg(value_name = "PACKAGES")]
packages: Vec<String>,
/// Only the project's direct dependencies (`--direct` / `-D`).
#[arg(short = 'D', long = "direct")]
direct: bool,
/// Only packages with a new major version.
#[arg(long = "major-only")]
major_only: bool,
/// Only packages with a new minor version.
#[arg(long = "minor-only")]
minor_only: bool,
/// Only packages with a new patch version.
#[arg(long = "patch-only")]
patch_only: bool,
/// Skip dev dependencies.
#[arg(long = "no-dev")]
no_dev: bool,
/// Exit non-zero if any package is outdated.
#[arg(long = "strict")]
strict: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Install everything the project requires.
#[command(display_order = 6)]
Sync {
/// Don't try to download anything, this will fail if there are uncached packages.
#[arg(long)]
offline: bool,
/// Show the plan, change nothing on disk.
#[arg(long)]
dry_run: bool,
/// Run composer.json root scripts for this sync, overriding
/// `[scripts] run` in bougie.toml. Off by default (opt-in).
#[arg(long, conflicts_with = "no_scripts")]
scripts: bool,
/// Skip composer.json root scripts for this sync, overriding
/// `[scripts] run = true` in bougie.toml.
#[arg(long = "no-scripts")]
no_scripts: bool,
#[command(flatten)]
php: PhpPrefArgs,
},
/// Run a command in the project environment.
#[command(display_order = 5)]
Run {
/// Add a temporary extension for this invocation.
#[arg(long, value_name = "EXT=VER")]
with: Vec<String>,
/// Skip the implicit `bougie sync` before running.
#[arg(long)]
no_sync: bool,
/// Layer the server's debug overlay (`vendor/bougie/conf.d-debug/`)
/// into `PHP_INI_SCAN_DIR` and set `XDEBUG_SESSION=1` for the
/// child. Installs xdebug on first use if not already present.
#[arg(long)]
xdebug: bool,
/// Run with a specific PHP interpreter. Accepts a version
/// (`8.3`, `8.3.12`), a constraint (`~8.3`, `>=8.2,<8.4`), or a
/// path to a `php` binary. Forces a sync to that interpreter,
/// so it can't be combined with `--no-sync`. Mirrors
/// `uv run --python`.
#[arg(long = "php", value_name = "VER|PATH", conflicts_with = "no_sync")]
php_request: Option<String>,
#[command(flatten)]
php: PhpPrefArgs,
/// Command and arguments. `--` separator is optional.
#[arg(trailing_var_arg = true, allow_hyphen_values = true, required = true)]
argv: Vec<String>,
},
/// Manage PHP interpreters.
#[command(subcommand, display_order = 20)]
Php(PhpCommand),
/// Manage Node.js interpreters (for projects that build frontend
/// assets — Vite, Laravel Mix, Magento static-content deploy).
#[command(subcommand, display_order = 21)]
Node(NodeCommand),
/// Run Composer, reimplemented natively. bougie does not bundle or
/// execute the Composer phar; the common Composer surface
/// (install/update/require/remove/show/why/why-not/outdated/audit/
/// licenses/fund/status/validate/dump-autoload) runs natively, and an
/// unrecognized subcommand errors with a pointer to
/// `bougie tool install composer/composer` for the full upstream
/// Composer.
#[command(subcommand, display_order = 16)]
Composer(ComposerCommand),
/// Manage globally-installed, isolated PHP CLI tools. See
/// `TOOL_PLAN.md` for the design.
#[command(subcommand, display_order = 22)]
Tool(ToolCommand),
/// Runtime shim invoked by tool wrappers (`#!.../bougie tool-exec`).
/// Not for direct CLI use; hidden from `--help`.
#[command(hide = true, name = "tool-exec")]
ToolExec {
/// Path to the tool wrapper script the kernel handed us as
/// argv[1] via the shebang.
wrapper: std::path::PathBuf,
/// User-supplied arguments to the tool, passed through to PHP.
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<std::ffi::OsString>,
},
/// Manage bougie's cache.
#[command(subcommand, display_order = 40)]
Cache(CacheCommand),
/// Manage the bougie binary itself.
#[command(subcommand)]
#[command(name = "self", display_order = 41)]
SelfCmd(SelfCommand),
/// Run the bougie development HTTP server for the current project.
/// With no subcommand, registers the project with the shared dev
/// server, prints its URL, and streams its log (Ctrl-C detaches).
/// See SERVER.md.
#[command(display_order = 30)]
Server(ServerArgs),
/// Manage project-scoped dev services (mariadb, redis, …). See
/// SERVICES.md and CLI.md §3.8.
#[command(subcommand, display_order = 31)]
Services(ServicesCommand),
/// Inspect and manage provisioned tenants across the shared dev
/// services and the project each belongs to. Reads the on-disk
/// tenant ledgers; no daemon required.
#[command(subcommand, display_order = 32)]
Projects(ProjectsCommand),
/// Bring the whole project up: run the detected recipe's `start`
/// task, whose DAG syncs the toolchain + vendor, provisions and
/// starts the project's services, runs any setup, and starts the
/// dev server. The project lifecycle umbrella (ddev's `start`).
/// For an individual task use `bougie make <task>`. Unix-only.
#[command(display_order = 3)]
Start {
/// Skip the implicit `bougie sync` prologue.
#[arg(long)]
no_sync: bool,
/// Show what would run, but don't execute.
#[arg(long)]
dry_run: bool,
/// Explain why each step runs or skips.
#[arg(long)]
explain: bool,
/// Ignore the builtin recipe; use only `bougie.toml`.
#[arg(long)]
no_builtin: bool,
/// Force a specific builtin (e.g. `magento`).
#[arg(long, value_name = "NAME")]
recipe: Option<String>,
},
/// Bring the project down: stop its declared services (or every
/// service in `names`), including the dev-server tenant when the
/// `server` service is declared. The shared daemon and any other
/// project's tenants stay up. The teardown twin of `bougie start`.
/// Unix-only.
#[command(display_order = 4)]
Stop {
/// Service names to stop. Empty = every declared service.
names: Vec<String>,
/// Destroy persisted tenant data (e.g. FLUSHDB on redis). Off
/// by default — `bougie start` should restore state.
#[arg(long)]
purge: bool,
},
/// Walk a project recipe's DAG, running tasks whose freshness
/// check fails. With no task, lists the available tasks; use
/// `bougie start` to bring the whole project up. See RECIPES.md.
#[command(display_order = 7)]
Make {
/// Task to run. With none, the available tasks are listed.
task: Option<String>,
/// List available tasks instead of running.
#[arg(long, conflicts_with_all = ["dry_run", "explain", "print"])]
list: bool,
/// Show what would run, but don't execute.
#[arg(long)]
dry_run: bool,
/// Explain why each step runs or skips.
#[arg(long)]
explain: bool,
/// Skip the implicit `bougie sync` prologue.
#[arg(long)]
no_sync: bool,
/// Ignore the builtin recipe; use only `bougie.toml`.
#[arg(long)]
no_builtin: bool,
/// Force a specific builtin (e.g. `magento`).
#[arg(long, value_name = "NAME")]
recipe: Option<String>,
/// Print the merged recipe to stdout instead of running.
#[arg(long)]
print: bool,
},
/// Format the project's PHP, the way `uv format` runs ruff.
///
/// bougie does not bundle a formatter: on first use it downloads a
/// pinned `wick` binary (cresset-tools/wick — an unconfigurable,
/// Laravel Pint-style formatter), caches it, and execs it. Every
/// argument is forwarded verbatim to `wick`, so `bougie format`,
/// `bougie format --check`, `bougie format src/ --diff`, and
/// `… | bougie format -` behave exactly like the matching `wick`
/// invocation. Pin a specific wick with `BOUGIE_WICK_VERSION`.
#[command(display_order = 8)]
Format {
/// Arguments forwarded verbatim to `wick` (paths, `--check`,
/// `--diff`, `-` for stdin, …).
#[arg(trailing_var_arg = true, allow_hyphen_values = true, value_name = "ARGS")]
args: Vec<std::ffi::OsString>,
},
}
#[derive(Subcommand, Debug)]
pub enum ServicesCommand {
/// Start the project's declared services (or every service in
/// `names`) and provision the project's tenant in each. For the
/// whole-project bring-up use `bougie start`.
Up {
/// Service names to bring up. Empty = every declared service.
names: Vec<String>,
/// Start the services and return immediately instead of
/// attaching to their combined log stream. Attaching is the
/// default for an interactive (TTY) text-mode invocation;
/// non-interactive runs and `--format json-v1` always detach.
#[arg(short = 'd', long)]
detach: bool,
},
/// Stop the project's declared services (or every service in
/// `names`). The shared global process stays up while any other
/// project's tenant remains. For the whole-project teardown use
/// `bougie stop`.
Down {
names: Vec<String>,
/// Destroy persisted tenant data (e.g. FLUSHDB on redis). Off
/// by default — re-adding the service should restore state.
#[arg(long)]
purge: bool,
},
/// Declare a service in the project. Errors if the name isn't in
/// the catalog. Use `bougie services catalog` to discover names.
Add {
/// One or more service names, each optionally `@<version>`.
names: Vec<String>,
},
/// Remove a service declaration from the project. Tenant data is
/// kept by default (re-adding restores it); pass `--purge` to also
/// destroy it.
Remove {
/// Service names to remove.
names: Vec<String>,
/// Also destroy the project's tenant data for each service
/// (same as `bougie services down --purge`) before undeclaring.
#[arg(long)]
purge: bool,
},
/// List the services declared in the current project.
List {
/// Reserved for cross-project listing in Phase 3+. Today this
/// degrades silently to per-project output.
#[arg(long)]
all: bool,
},
/// Print the built-in service catalog (no daemon required).
Catalog,
/// Restart the named services (or every declared service). Stops
/// then starts the underlying global process; the tenant ledger
/// is preserved, so generated passwords / DB numbers survive.
/// Affects every project sharing the same service.
Restart {
names: Vec<String>,
},
/// Per-service status for the current project.
Status {
/// Limit to a single service.
name: Option<String>,
},
/// Tail (and optionally follow) service logs. With no name, shows
/// the combined ("multilog") stream of every service declared in the
/// project, each line prefixed with its (colorized) service name —
/// the same view `bougie services up` attaches to.
Logs {
/// Service name. Omit to tail every declared service at once.
name: Option<String>,
/// Follow the log; runs until interrupted (Ctrl-C).
#[arg(short = 'f', long)]
follow: bool,
/// Number of trailing lines to print before any follow.
#[arg(short = 'n', long, default_value_t = 50)]
lines: usize,
},
/// Inspect and control the `bougied` daemon.
#[command(subcommand)]
Daemon(ServicesDaemonCommand),
}
#[derive(Subcommand, Debug)]
pub enum ProjectsCommand {
/// List every provisioned tenant across the shared services and the
/// project each belongs to. Reads the on-disk tenant ledgers; no
/// daemon required.
List {
/// Show the per-service allocation (redis db number, rabbitmq
/// vhost, server hostname, …) as an extra column.
#[arg(long)]
alloc: bool,
},
/// Deprovision tenants and remove them from the service ledgers.
/// With no flags, targets *orphaned* tenants whose project directory
/// no longer exists. Destructive: when the service is running this
/// drops the tenant's data (database, vhost, redis db, …); when it's
/// stopped, only the ledger entry is removed.
Purge {
/// Purge a specific project's tenants by path (it may already be
/// deleted) instead of the orphaned set.
#[arg(long)]
project: Option<String>,
/// Purge every tenant of every project. Use with care.
#[arg(long)]
all: bool,
/// Print what would be purged and exit without changing anything.
#[arg(long)]
dry_run: bool,
/// Skip the confirmation prompt (required for non-interactive use).
#[arg(short = 'y', long)]
yes: bool,
},
}
#[derive(Subcommand, Debug)]
pub enum ServicesDaemonCommand {
/// Print daemon PID, socket path, and managed-service count. The
/// daemon is auto-spawned if not already running.
Status,
/// Send a graceful shutdown to the running daemon.
Stop,
/// Print the daemon's reported version (used by the CLI to detect
/// post-`self update` daemon-binary mismatches).
Version,
}
/// `bougie server` — the project verb plus its management subcommands.
/// With no subcommand, the flattened [`ServeArgs`] drive the default
/// "serve the current project" action; otherwise a [`ServerCommand`]
/// runs.
#[derive(Args, Debug)]
#[command(args_conflicts_with_subcommands = true)]
pub struct ServerArgs {
#[command(subcommand)]
pub command: Option<ServerCommand>,
#[command(flatten)]
pub serve: ServeArgs,
}
/// Default-action arguments for `bougie server` (no subcommand):
/// register the current project with the shared dev server, print its
/// URL, and stream its log.
#[derive(Args, Debug)]
#[allow(clippy::struct_excessive_bools)] // each bool is a distinct CLI flag
pub struct ServeArgs {
/// Hostname label override — the `<name>` in `<name>.bougie.run`.
/// Defaults to a name derived from the project.
#[arg(value_name = "NAME")]
pub name: Option<String>,
/// Open the project URL in a browser once the server is ready.
#[arg(long)]
pub open: bool,
/// Serve over HTTPS (requires `bougie server tls install`).
#[arg(long)]
pub tls: bool,
/// Print the URL and return immediately instead of attaching to the
/// log stream. Matches `services up`'s `-d`.
#[arg(short = 'd', long = "detach")]
pub detach: bool,
/// Skip the implicit `bougie sync` before serving.
#[arg(long)]
pub no_sync: bool,
}
#[derive(Subcommand, Debug)]
pub enum ServerCommand {
/// Low-level primitive: run the server process against an explicit
/// multi-host `server.toml`, foreground, with no daemon. This is
/// what `bougied` spawns and what CI / power users invoke directly;
/// `--config` is required because a multi-host server has no single
/// project to default to. The bougied-managed path (`bougie services
/// up server`) supplies its own service-scoped `server.toml`.
Run {
/// `server.toml` path. Required.
#[arg(long, value_name = "PATH")]
config: std::path::PathBuf,
/// CLI override of `[server].listen` (e.g. `127.0.0.1:7080`).
#[arg(long, value_name = "ADDR")]
listen: Option<String>,
/// CLI override of `[server].log_format`.
#[arg(long, value_name = "FMT")]
log_format: Option<String>,
},
/// Show the dev server's hosts and live pool state. Reads the
/// running server's control socket when available, falling back to
/// the configured hosts otherwise. Replaces the old `list`, which
/// remains as a hidden alias.
#[command(alias = "list")]
Status {
/// `server.toml` to inspect. Defaults to the bougied-managed
/// config.
#[arg(long, value_name = "PATH")]
config: Option<std::path::PathBuf>,
},
/// Open the current project's (or NAME's) dev URL in a browser.
Open {
/// Hostname label to open. Defaults to the current project.
#[arg(value_name = "NAME")]
name: Option<String>,
},
/// Stop the shared dev server. Equivalent to `bougie services down
/// server`; stops hosting for every project, since the server is shared.
Stop,
/// Tail the dev server's request log. In a project, defaults to
/// this project's host.
Logs {
/// Follow the log; runs until interrupted (Ctrl-C).
#[arg(short = 'f', long)]
follow: bool,
/// Number of trailing lines to print before any follow.
#[arg(short = 'n', long, default_value_t = 50)]
lines: usize,
},
/// Manage local TLS via mkcert.
#[command(subcommand)]
Tls(ServerTlsCommand),
/// Manage `/etc/hosts` overrides.
#[command(subcommand)]
Hosts(ServerHostsCommand),
}
#[derive(Subcommand, Debug)]
pub enum ServerHostsCommand {
/// Rewrite the bougie sentinel block in /etc/hosts to match
/// server.toml. Requires root — runs via sudo.
Apply {
/// `server.toml` to read the host list from. Defaults to the
/// bougied-managed config.
#[arg(long, value_name = "PATH")]
config: Option<std::path::PathBuf>,
},
}
#[derive(Subcommand, Debug)]
pub enum ServerTlsCommand {
/// Fetch mkcert and install bougie's local CA.
Install,
/// Uninstall bougie's local CA.
Uninstall,
}
#[derive(Subcommand, Debug)]
pub enum ExtCommand {
/// Add an extension dependency. Each `<arg>` is either an
/// extension name (e.g. `redis`, `xdebug@3.5.1`) — fetched from
/// the index and recorded in composer.json — or a path to a local
/// `.so` file (e.g. `/opt/tideways/tideways-php-8.5.so`), in which
/// case bougie copies it into the store, auto-detects the
/// extension name and Zend-ness from the binary, and writes a
/// fragment to the durable, machine-local `conf.d-local/` (under
/// `$BOUGIE_HOME`) without touching composer.json. Mix and match in
/// one invocation.
Add {
/// Extension names or `.so` paths (anything ending in `.so` is
/// treated as a local file).
args: Vec<String>,
/// Skip the implicit `bougie sync` after the composer call.
#[arg(long)]
no_sync: bool,
#[command(flatten)]
php: PhpPrefArgs,
},
/// Remove an extension dependency.
Remove {
/// The extension(s) to remove.
names: Vec<String>,
/// Skip the implicit `bougie sync` after the composer call.
#[arg(long)]
no_sync: bool,
},
/// List available extensions.
List {
/// Only show installed extensions.
#[arg(long)]
only_installed: bool,
/// Only show extensions advertised by the index.
#[arg(long)]
only_available: bool,
/// List all extension versions, including older releases.
#[arg(long)]
all_versions: bool,
/// List extensions for all platforms, not just the host's.
#[arg(long)]
all_platforms: bool,
/// Show the URLs of available extension downloads.
#[arg(long)]
show_urls: bool,
},
}
#[derive(Subcommand, Debug)]
pub enum PhpCommand {
/// Install a new PHP version.
Install {
/// The PHP version(s) to install (e.g. `8.3`, `8.3.12`, `8.3+zts`).
requests: Vec<String>,
/// Build flavor to install [possible values: nts, nts-debug, zts, zts-debug].
#[arg(long)]
flavor: Option<String>,
/// Skip the entire baseline extension set; install only the bare
/// Debian-aligned interpreter (`REFACTOR_DEBIAN_ALIGNED.md`).
#[arg(long, conflicts_with = "without")]
bare: bool,
/// Skip a specific baseline extension. Repeatable: `--without opcache
/// --without readline`. The named extensions must already be in the
/// baseline set; use `bougie ext remove` after install for anything else.
#[arg(long, value_name = "EXT", action = clap::ArgAction::Append)]
without: Vec<String>,
},
/// Remove a PHP version.
Uninstall {
/// The PHP version(s) to uninstall.
#[arg(required = true)]
requests: Vec<String>,
/// Build flavor to uninstall [possible values: nts, nts-debug, zts, zts-debug].
#[arg(long)]
flavor: Option<String>,
},
/// List available PHP interpreters.
List {
/// A PHP request to filter by.
request: Option<String>,
/// Only show installed PHP versions.
#[arg(long)]
only_installed: bool,
/// Only show PHP versions available for download.
#[arg(long)]
only_available: bool,
/// List all PHP versions, including older patch versions.
#[arg(long)]
all_versions: bool,
/// List PHP downloads for all platforms.
#[arg(long)]
all_platforms: bool,
/// List PHP downloads for all architectures.
#[arg(long)]
all_arches: bool,
/// Show the URLs of available PHP downloads.
#[arg(long)]
show_urls: bool,
},
/// Search for a PHP interpreter.
Find {
/// A PHP request to search for.
request: Option<String>,
},
/// Pin the project's PHP version.
Pin {
/// The PHP version to pin.
request: String,
/// Write the pin to `bougie.toml` (creating it if needed).
#[arg(long, conflicts_with = "composer")]
toml: bool,
/// Write the pin to `composer.json`'s `require.php`.
#[arg(long, conflicts_with = "toml")]
composer: bool,
},
/// Refresh installed interpreters to the latest published patch.
Upgrade {
/// The PHP minor version(s) to upgrade (e.g. `8.3`).
minor: Option<String>,
},
/// Show the PHP interpreter installation directory.
Dir,
}
#[derive(Subcommand, Debug)]
pub enum NodeCommand {
/// Install a Node.js version from nodejs.org.
Install {
/// The Node version(s) to install (e.g. `latest`, `lts`, `20`,
/// `20.11`, `20.11.0`). Defaults to `latest`.
requests: Vec<String>,
},
/// Remove an installed Node.js version.
Uninstall {
/// The Node version(s) to uninstall (exact `20.11.0`).
#[arg(required = true)]
requests: Vec<String>,
},
/// List installed Node.js versions.
List,
/// Resolve a request and show the version + download URL it maps to,
/// without installing.
Find {
/// A Node request to resolve (e.g. `lts`, `20`). Defaults to `latest`.
request: Option<String>,
},
/// Show the Node.js installation directory.
Dir,
}
#[derive(Subcommand, Debug)]
pub enum ComposerCommand {
/// Install a project's `vendor/` from `composer.lock`. Reads
/// `composer.json` + `composer.lock` in the working directory,
/// content-hash-verifies the lock, parallel-downloads dists into
/// `vendor/`, and emits `vendor/autoload.php`.
Install {
/// Run the install in this directory instead of CWD.
/// Mirrors Composer's `--working-dir` / `-d`.
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Skip dev-only packages and dev autoload entries.
#[arg(long = "no-dev")]
no_dev: bool,
/// Fail if composer.lock is out of sync with composer.json.
/// Currently a no-op — the install already errors on
/// content-hash mismatch by default. Accepted for parity
/// with Composer's CI usage.
#[arg(long = "frozen")]
frozen: bool,
/// Verify the lock is internally consistent (content-hash,
/// requires, transitives) and exit. Doesn't touch `vendor/`
/// or run the autoloader. CI-friendly read-only check.
#[arg(long = "lock-verify")]
lock_verify: bool,
/// Ignore all platform requirements (php, ext-*, lib-*).
/// Accepted for Composer parity; bougie does not enforce
/// platform requirements yet.
#[arg(long = "ignore-platform-reqs")]
ignore_platform_reqs: bool,
/// Ignore a specific platform requirement.
#[arg(long = "ignore-platform-req", value_name = "REQ")]
ignore_platform_req: Vec<String>,
/// Run composer.json root scripts, overriding `[scripts] run`
/// in bougie.toml. Off by default (opt-in).
#[arg(long, conflicts_with = "no_scripts")]
scripts: bool,
/// Skip composer.json root scripts, overriding `[scripts] run
/// = true` in bougie.toml (Composer-compatible `--no-scripts`).
#[arg(long = "no-scripts")]
no_scripts: bool,
},
/// Resolve the project's dependency graph, write a fresh
/// `composer.lock`, and install the result into `vendor/` (matching
/// Composer's `update`). With no package arguments this re-resolves
/// from scratch; naming one or more packages does a partial update —
/// only those re-resolve while every other locked package stays
/// pinned. `--no-install` stops after writing the lock; `--dry-run`
/// previews the solution without writing anything. Aliased to
/// `upgrade` / `u`, like Composer.
#[command(visible_alias = "upgrade", alias = "u")]
Update {
/// Packages to update (`vendor/name`). When given, only these
/// packages re-resolve; every other package stays pinned to its
/// `composer.lock` version (Composer's partial update). With no
/// packages, the whole graph re-resolves from scratch.
#[arg(value_name = "PACKAGES")]
packages: Vec<String>,
/// Write the lock but don't install into `vendor/` (Composer's
/// `--no-install`).
#[arg(long = "no-install")]
no_install: bool,
/// Also update the named packages' dependencies (Composer's
/// `--with-dependencies` / `-w`).
#[arg(short = 'w', long = "with-dependencies")]
with_dependencies: bool,
/// Also update all of the named packages' dependencies, including
/// ones shared with other packages (Composer's
/// `--with-all-dependencies` / `-W`).
#[arg(short = 'W', long = "with-all-dependencies")]
with_all_dependencies: bool,
/// Run the update in this directory instead of CWD.
/// Mirrors Composer's `--working-dir` / `-d`.
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Skip dev-only root requires when resolving.
#[arg(long = "no-dev")]
no_dev: bool,
/// Resolve and print the solution without writing
/// `composer.lock` or touching `vendor/`. Without this flag,
/// `update` writes a fresh `composer.lock`.
#[arg(long = "dry-run")]
dry_run: bool,
/// Ignore all platform requirements (php, ext-*, lib-*).
/// Accepted for Composer parity; bougie does not enforce
/// platform requirements yet.
#[arg(long = "ignore-platform-reqs")]
ignore_platform_reqs: bool,
/// Ignore a specific platform requirement.
#[arg(long = "ignore-platform-req", value_name = "REQ")]
ignore_platform_req: Vec<String>,
},
/// Validate composer.json structure and contents.
Validate {
/// Run in this directory instead of CWD.
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Return non-zero exit code for warnings too.
#[arg(long)]
strict: bool,
/// Skip lock file freshness check.
#[arg(long = "no-check-lock")]
no_check_lock: bool,
/// Skip publish-only checks (name casing, required fields).
#[arg(long = "no-check-publish")]
no_check_publish: bool,
/// Skip unbound/exact version constraint warnings.
#[arg(long = "no-check-all")]
no_check_all: bool,
/// Also validate installed dependencies' composer.json files.
#[arg(long = "with-dependencies")]
with_dependencies: bool,
/// Force lock file checking even when `config.lock` is false.
#[arg(long = "check-lock")]
check_lock: bool,
},
/// Regenerate `vendor/composer/autoload_*.php` against the current
/// `composer.lock`. Drop-in for `composer dump-autoload`; output
/// is byte-equivalent to Composer 2.8.12 with the same flags. Aliased
/// to `dump-autoload` for users coming from Composer muscle-memory.
#[command(alias = "dump-autoload")]
DumpAutoloader {
/// Optimize the classmap (`--optimize` / `-o`).
#[arg(short = 'o', long = "optimize", alias = "optimize-autoloader")]
optimize: bool,
/// Emit the classmap-authoritative static loader
/// (`--classmap-authoritative` / `-a`). Implies `--optimize`.
#[arg(short = 'a', long = "classmap-authoritative")]
classmap_authoritative: bool,
/// Skip dev autoload entries (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// Emit the `APCu` loader bootstrap (`--apcu-autoloader`).
#[arg(long = "apcu-autoloader")]
apcu_autoloader: bool,
/// Explicit `APCu` prefix; implies `--apcu-autoloader`.
#[arg(long = "apcu-autoloader-prefix", value_name = "PREFIX")]
apcu_prefix: Option<String>,
/// Override the `ComposerAutoloaderInit<X>` class suffix —
/// otherwise the value from `composer.json`'s
/// `config.autoloader-suffix`, or the `composer.lock`
/// content-hash.
#[arg(long = "autoloader-suffix", value_name = "SUFFIX")]
autoloader_suffix: Option<String>,
/// Run the dump in this directory instead of the current one.
/// Mirrors Composer's `--working-dir` / `-d`.
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Add one or more packages to `composer.json` `require` (or
/// `require-dev`), re-resolve `composer.lock`, and install them.
/// Fully Composer-compatible: a bare `vendor/pkg` resolves the
/// latest stable and writes a caret (`^X.Y`) constraint; supply an
/// explicit constraint with `vendor/pkg:^1.0`, `vendor/pkg=^1.0`, or
/// a trailing argument (`vendor/pkg ^1.0`) — Composer's separators
/// are `:`, `=`, or a space (the `@` separator is *not* accepted, as
/// in Composer). For bougie's `>=`-default + `@`-syntax house style,
/// use the top-level `bougie add` instead.
Require {
/// Packages to require, as Composer name↔version pairs.
#[arg(value_name = "PACKAGES", required = true)]
packages: Vec<String>,
/// Add to `require-dev` instead of `require`.
#[arg(long = "dev")]
dev: bool,
/// Edit `composer.json` only — don't re-resolve `composer.lock`
/// or touch `vendor/` (Composer's `--no-update`).
#[arg(long = "no-update")]
no_update: bool,
/// Re-resolve and write `composer.lock` but don't install into
/// `vendor/` (Composer's `--no-install`).
#[arg(long = "no-install")]
no_install: bool,
/// Also update the new packages' dependencies (`-w`).
#[arg(short = 'w', long = "with-dependencies")]
with_dependencies: bool,
/// Also update all dependencies, including shared ones (`-W`).
#[arg(short = 'W', long = "with-all-dependencies")]
with_all_dependencies: bool,
/// Prefer the lowest matching versions when resolving.
#[arg(long = "prefer-lowest")]
prefer_lowest: bool,
/// Ignore all platform requirements (php, ext-*, lib-*).
#[arg(long = "ignore-platform-reqs")]
ignore_platform_reqs: bool,
/// Ignore a specific platform requirement.
#[arg(long = "ignore-platform-req", value_name = "REQ")]
ignore_platform_req: Vec<String>,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Resolve and report what would change without writing
/// `composer.json`, `composer.lock`, or `vendor/`.
#[arg(long = "dry-run")]
dry_run: bool,
},
/// Remove one or more packages from `composer.json`, re-resolve
/// `composer.lock`, and uninstall them from `vendor/`. Drop-in for
/// `composer remove`.
Remove {
/// Packages to remove (`vendor/name`).
#[arg(value_name = "PACKAGES", required = true)]
packages: Vec<String>,
/// Remove from `require-dev` instead of `require`.
#[arg(long = "dev")]
dev: bool,
/// Edit `composer.json` only — don't re-resolve or touch
/// `vendor/` (Composer's `--no-update`).
#[arg(long = "no-update")]
no_update: bool,
/// Re-resolve and write `composer.lock` but don't touch
/// `vendor/` (Composer's `--no-install`).
#[arg(long = "no-install")]
no_install: bool,
/// Skip dev-only packages when resolving.
#[arg(long = "no-dev")]
no_dev: bool,
/// Ignore all platform requirements (php, ext-*, lib-*).
#[arg(long = "ignore-platform-reqs")]
ignore_platform_reqs: bool,
/// Ignore a specific platform requirement.
#[arg(long = "ignore-platform-req", value_name = "REQ")]
ignore_platform_req: Vec<String>,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
/// Resolve and report what would change without writing
/// `composer.json`, `composer.lock`, or `vendor/`.
#[arg(long = "dry-run")]
dry_run: bool,
},
/// List installed packages, or show details for one. Reads the
/// project's `composer.lock`. Drop-in for `composer show` (aliases
/// `info`, `list`).
#[command(alias = "info", alias = "list")]
Show {
/// A single `vendor/name` to show details for. With no argument,
/// every installed package is listed.
#[arg(value_name = "PACKAGE")]
package: Option<String>,
/// Render the dependency tree (`--tree` / `-t`).
#[arg(short = 't', long = "tree")]
tree: bool,
/// Only the project's direct dependencies (`--direct` / `-D`).
#[arg(short = 'D', long = "direct")]
direct: bool,
/// Only platform packages — php, ext-*, lib-* (`--platform` / `-p`).
#[arg(short = 'p', long = "platform")]
platform: bool,
/// Show the root package's own info (`--self` / `-s`).
#[arg(short = 's', long = "self")]
self_: bool,
/// Print package names only (`--name-only` / `-N`).
#[arg(short = 'N', long = "name-only")]
name_only: bool,
/// Show each package's install path (`--path` / `-P`).
#[arg(short = 'P', long = "path")]
path: bool,
/// Also fetch and show the latest available version
/// (`--latest` / `-l`).
#[arg(short = 'l', long = "latest")]
latest: bool,
/// Only packages with a newer version available
/// (`--outdated` / `-o`). Implies `--latest`.
#[arg(short = 'o', long = "outdated")]
outdated: bool,
/// Skip dev dependencies (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Show which packages depend on a given package — i.e. why it's
/// installed. Drop-in for `composer why` (alias `depends`).
#[command(alias = "depends")]
Why {
/// The package to explain.
#[arg(value_name = "PACKAGE", required = true)]
package: String,
/// Recurse through the dependency chain (`--recursive` / `-r`).
#[arg(short = 'r', long = "recursive")]
recursive: bool,
/// Render the full dependency-of tree (`--tree` / `-t`).
#[arg(short = 't', long = "tree")]
tree: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Show what prevents a package (optionally at a version) from being
/// installed — conflicting requirements. Drop-in for
/// `composer why-not` (alias `prohibits`).
#[command(name = "why-not", alias = "prohibits")]
WhyNot {
/// The package to test.
#[arg(value_name = "PACKAGE", required = true)]
package: String,
/// The version (or constraint) to test against. Defaults to `*`.
#[arg(value_name = "VERSION")]
version: Option<String>,
/// Recurse through the dependency chain (`--recursive` / `-r`).
#[arg(short = 'r', long = "recursive")]
recursive: bool,
/// Render the full tree (`--tree` / `-t`).
#[arg(short = 't', long = "tree")]
tree: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// List installed packages that have a newer version available.
/// Drop-in for `composer outdated` (a focused `show --latest
/// --outdated`). Use the global `--format json` for JSON output.
Outdated {
/// Optional `vendor/name` filters; with none, all packages are
/// considered.
#[arg(value_name = "PACKAGES")]
packages: Vec<String>,
/// Only the project's direct dependencies (`--direct` / `-D`).
#[arg(short = 'D', long = "direct")]
direct: bool,
/// Only show packages with a new major version (`--major-only`).
#[arg(long = "major-only")]
major_only: bool,
/// Only show packages with a new minor version (`--minor-only`).
#[arg(long = "minor-only")]
minor_only: bool,
/// Only show packages with a new patch version (`--patch-only`).
#[arg(long = "patch-only")]
patch_only: bool,
/// Skip dev dependencies (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// Exit non-zero if any package is outdated (`--strict`).
#[arg(long = "strict")]
strict: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Check installed packages against the Packagist security-advisories
/// database. Drop-in for `composer audit`. Exits non-zero when
/// advisories are found. Use the global `--format json` for JSON.
Audit {
/// Skip dev dependencies (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// How to treat abandoned packages (`--abandoned`). Currently
/// accepted for parity; abandoned detection is not yet wired.
#[arg(long = "abandoned", value_enum, default_value = "report")]
abandoned: AbandonedHandling,
/// Audit the locked set (`--locked`). bougie always reads
/// `composer.lock`, so this is the default behavior; accepted
/// for parity.
#[arg(long = "locked")]
locked: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// List the license of every installed package. Drop-in for
/// `composer licenses`. Use the global `--format json` for JSON.
Licenses {
/// Skip dev dependencies (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Report packages that look locally modified. Drop-in for
/// `composer status`. bougie installs from dist archives, so for the
/// common case this reports "no local changes".
Status {
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Show funding information for installed packages, grouped by
/// vendor. Drop-in for `composer fund`. Use `--format json` for JSON.
Fund {
/// Skip dev dependencies (`--no-dev`).
#[arg(long = "no-dev")]
no_dev: bool,
/// Run in this directory instead of CWD (`-d`).
#[arg(short = 'd', long = "working-dir", value_name = "DIR")]
working_dir: Option<std::path::PathBuf>,
},
/// Catch-all for any composer subcommand bougie does not implement
/// natively (`create-project`, `archive`, `bump`, `global`, …).
/// bougie does not bundle the Composer phar, so these no longer run;
/// the dispatch returns an error pointing at
/// `bougie tool install composer/composer` for the full upstream
/// Composer.
#[command(external_subcommand)]
External(Vec<OsString>),
}
/// How `composer audit` treats abandoned packages.
#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
pub enum AbandonedHandling {
/// Ignore abandoned packages entirely.
Ignore,
/// Report abandoned packages but don't fail on them.
Report,
/// Treat abandoned packages as an audit failure.
Fail,
}
#[derive(Subcommand, Debug)]
pub enum CacheCommand {
/// Wipe the full cache.
Clean,
/// Remove unneeded library files.
Prune {
/// Show what would be pruned without removing anything.
#[arg(long)]
dry_run: bool,
/// Also remove tracked projects that no longer exist on disk.
#[arg(long)]
prune_projects: bool,
},
/// Show the location of the cache directory.
Dir,
/// Show the cache size.
Size,
}
#[derive(Subcommand, Debug)]
pub enum ToolCommand {
/// Install a tool. Pass `<vendor>/<name>` optionally followed by
/// `@<constraint>` (e.g. `phpstan/phpstan@^1.10`).
Install {
/// Composer package identifier, optionally with `@<constraint>`.
package: String,
/// Pin the tool to a specific PHP. Accepts a version (`8.3`,
/// `8.3.12`) or a constraint (`~8.3`, `>=8.2,<8.4`). When the
/// requested PHP isn't installed, bougie installs it
/// automatically. Defaults to the highest installed NTS PHP.
#[arg(long, value_name = "VER")]
php: Option<String>,
/// Additional Composer package (`vendor/name[@<constraint>]`)
/// or PHP extension (`intl`, `redis`) to install alongside the
/// tool. May be passed multiple times.
#[arg(long, value_name = "PKG_OR_EXT")]
with: Vec<String>,
/// Overwrite an existing executable at the bin-dir path.
#[arg(long)]
force: bool,
},
/// Remove an installed tool by its `<vendor>/<name>` identifier.
Uninstall {
/// Composer package identifier.
package: String,
},
/// Add an extra composer package or PHP extension to an
/// installed tool. Re-resolves the tool's lock and updates the
/// vendor tree in place.
Inject {
/// Composer package identifier of the tool.
package: String,
/// Extra to add (`vendor/name[@<constraint>]` for composer
/// packages, bare name for PHP extensions). Repeatable.
#[arg(long, value_name = "PKG_OR_EXT", required = true)]
with: Vec<String>,
},
/// Remove an extra previously added via `--with` / `inject`.
Uninject {
/// Composer package identifier of the tool.
package: String,
/// Extra to remove. Repeatable.
#[arg(long, value_name = "PKG_OR_EXT", required = true)]
with: Vec<String>,
},
/// List installed tools.
List,
/// Print a tool's install directory, or the tools root if no
/// package is given.
Dir {
/// Composer package identifier; omit to print the tools root.
package: Option<String>,
},
/// Run an installed-or-cached tool one-off. Reuses an existing
/// persistent install if `(package, constraint, php, with)` match
/// exactly; otherwise materialises into the ephemeral cache.
///
/// `bgx` is provided as a convenient alias for `bougie tool run`;
/// their behavior is identical.
#[command(
override_usage = "bougie tool run [OPTIONS] <PACKAGE> [ARGS]...",
after_help = "Use `bgx` as a shortcut for `bougie tool run`.\n\n\
Use `bougie help tool run` for more details.",
after_long_help = ""
)]
Run(ToolRunArgs),
// Hidden alias for `bougie tool run` for the `bgx` command. The
// variant is reached only via the `bgx` binary exec'ing into it;
// it doesn't surface under `bougie tool --help`. Carrying it as
// a separate variant (with `display_name`, `override_usage`)
// lets clap render `bgx --help` and clap-level error messages
// with `bgx` as the program name rather than leaking
// `bougie tool run`.
#[command(
hide = true,
override_usage = "bgx [OPTIONS] <PACKAGE> [ARGS]...",
about = "Run a tool from a Composer package.",
long_about = None,
after_help = "Use `bougie help tool run` for more details.",
after_long_help = "",
display_name = "bgx",
// `bgx --version` / `bgx -V` exec into `bougie tool bgx`; give
// this variant its own version flag so it short-circuits before
// the required `<PACKAGE>` positional and prints `bgx <version>`.
version = LONG_VERSION
)]
Bgx(BgxArgs),
/// Re-resolve a tool's lock and bring its vendor tree up to date.
/// Pass `--all` to walk every installed tool, or `--reinstall` to
/// wipe and rebuild from scratch (recovery for broken state).
Upgrade {
/// Composer package identifier. Required unless `--all`.
#[arg(required_unless_present = "all", conflicts_with = "all")]
package: Option<String>,
/// Upgrade every installed tool.
#[arg(long)]
all: bool,
/// Wipe the tool dir + every entrypoint symlink and reinstall
/// from scratch using the receipt's pinned `(package,
/// constraint, php_version, with, extensions)` tuple.
#[arg(long)]
reinstall: bool,
},
}
#[derive(Subcommand, Debug)]
pub enum SelfCommand {
/// Update bougie.
Update {
/// Update even when bougie can't confirm it installed this
/// binary. By default `self update` only touches a binary that
/// bougie's own installer placed (per the install receipt);
/// copies from a package manager, cargo, or nix are left for
/// that tool to update. Pass `--force` only if you know this
/// copy came from bougie's installer.
#[arg(long)]
force: bool,
},
/// Show bougie's version.
Version {
/// Only show the version.
#[arg(long)]
short: bool,
},
}
#[derive(Args, Debug)]
pub struct ToolRunArgs {
/// Pin the tool to a specific PHP for this run.
#[arg(long, value_name = "VER")]
pub php: Option<String>,
/// Extra composer package or PHP extension, same shape as
/// `tool install --with`. Repeatable.
#[arg(long, value_name = "PKG_OR_EXT")]
pub with: Vec<String>,
/// The tool's Composer package (optionally `@<constraint>`) followed
/// by the arguments to forward to it. bougie's own options must come
/// *before* the package; everything from the package onward is passed
/// to the tool verbatim, so no `--` separator is needed.
#[arg(
trailing_var_arg = true,
allow_hyphen_values = true,
required = true,
value_name = "PACKAGE"
)]
pub command: Vec<std::ffi::OsString>,
}
/// Args for the hidden `bgx` alias. Wraps [`ToolRunArgs`] verbatim so
/// the two variants share their entire surface; the wrapper exists
/// only so clap renders help / errors with `bgx` as the program name.
#[derive(Args, Debug)]
pub struct BgxArgs {
#[command(flatten)]
pub tool_run: ToolRunArgs,
}
#[cfg(test)]
mod tests {
use super::*;
use clap::Parser;
fn cmd(argv: &[&str]) -> Command {
Cli::try_parse_from(argv).expect("parse").command
}
#[test]
fn start_is_its_own_verb() {
assert!(matches!(cmd(&["bougie", "start"]), Command::Start { .. }));
assert!(matches!(
cmd(&["bougie", "start", "--no-sync", "--dry-run"]),
Command::Start { no_sync: true, dry_run: true, .. }
));
}
#[test]
fn stop_takes_names_and_purge() {
let Command::Stop { names, purge } = cmd(&["bougie", "stop", "redis", "--purge"]) else {
panic!("expected stop");
};
assert_eq!(names, ["redis"]);
assert!(purge);
}
#[test]
fn up_down_live_under_services() {
assert!(matches!(
cmd(&["bougie", "services", "up", "redis", "-d"]),
Command::Services(ServicesCommand::Up { detach: true, .. })
));
assert!(matches!(
cmd(&["bougie", "services", "down", "--purge"]),
Command::Services(ServicesCommand::Down { purge: true, .. })
));
}
#[test]
fn top_level_up_down_are_gone() {
// The deprecated top-level aliases were removed; `up`/`down` only
// exist under `services` now.
assert!(Cli::try_parse_from(["bougie", "up"]).is_err());
assert!(Cli::try_parse_from(["bougie", "down"]).is_err());
}
#[test]
fn server_detach_flag() {
for argv in [
&["bougie", "server", "-d"][..],
&["bougie", "server", "--detach"][..],
] {
let Command::Server(args) = cmd(argv) else {
panic!("expected server for {argv:?}");
};
assert!(args.serve.detach, "detach should be set for {argv:?}");
}
// The old `--no-attach` spelling is gone.
assert!(Cli::try_parse_from(["bougie", "server", "--no-attach"]).is_err());
}
#[test]
fn make_no_longer_aliases_start() {
// `start` is no longer a clap alias of `make`; it's the
// first-class verb above. `bougie make start` is just `make`
// with the literal task `start`.
let Command::Make { task, .. } = cmd(&["bougie", "make", "start"]) else {
panic!("expected make");
};
assert_eq!(task.as_deref(), Some("start"));
// Bare `bougie make` parses with no task; the dispatcher turns
// that into a task listing.
let Command::Make { task, .. } = cmd(&["bougie", "make"]) else {
panic!("expected make");
};
assert_eq!(task, None);
}
}