stout 0.2.1

A fast, Rust-based Homebrew-compatible package manager
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
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
# Usage Guide

This guide covers how to use stout for common package management tasks.

## Basic Commands

### Updating the Index

Before using stout for the first time, or to get the latest package information:

```bash
stout update
```

This downloads the latest formula index (~3MB) containing metadata for 8000+ packages.

### Searching for Packages

Search for packages by name or description:

```bash
# Basic search
stout search json

# Search with limit
stout search json --limit 10

# Search for exact name
stout search wget
```

Example output:

```
Found 20 formulas:

  jq              1.7.1   Lightweight and flexible command-line JSON processor
  json-c          0.18    JSON parser for C
  fx              35.0.0  Terminal JSON viewer
  gron            0.7.1   Make JSON greppable
  ...

Use 'stout info <formula>' for details
```

### Viewing Package Information

Get detailed information about a package:

```bash
stout info jq
```

Example output:

```
jq 1.7.1
Lightweight and flexible command-line JSON processor

Homepage:    https://jqlang.github.io/jq/
License:     MIT
Tap:         homebrew/core

Dependencies:
  └── oniguruma (runtime)

Bottles:
  ✓ arm64_sonoma  ✓ arm64_ventura  ✓ x86_64_linux  ...

Installed: No
```

### Installing Packages

Install one or more packages:

```bash
# Install a single package
stout install jq

# Install multiple packages
stout install jq yq gron

# Install with verbose output
stout install -v wget
```

stout will:
1. Resolve all dependencies
2. Download bottles in parallel
3. Extract to Cellar
4. Create symlinks

### Listing Installed Packages

View all installed packages:

```bash
# List all installed packages
stout list

# List only explicitly installed (not dependencies)
stout list --requested
```

### Uninstalling Packages

Remove installed packages:

```bash
# Uninstall a package
stout uninstall jq

# Uninstall multiple packages
stout uninstall jq yq gron
```

### Upgrading Packages

Upgrade installed packages to latest versions:

```bash
# Upgrade all packages
stout upgrade

# Upgrade specific packages
stout upgrade jq wget
```

### System Health Check

Check if your system is properly configured:

```bash
stout doctor
```

This checks:
- stout data directory
- Configuration file
- Formula index
- Homebrew prefix and Cellar
- Installed packages state
- Homebrew drift
- Unrelocated placeholders
- Code signatures (macOS)

## Command Reference

### Global Options

These options work with any command:

```bash
-v, --verbose    Enable verbose output
-q, --quiet      Suppress output
-h, --help       Print help
-V, --version    Print version
```

### stout install

```bash
stout install [OPTIONS] <PACKAGES>...

Arguments:
  <PACKAGES>...  Packages to install

Options:
  -f, --force          Force reinstall if already installed
  -n, --dry-run        Show what would be installed
  --build-from-source  Build from source instead of using bottles
  -v, --verbose        Enable verbose output
```

### stout uninstall

```bash
stout uninstall [OPTIONS] <PACKAGES>...

Arguments:
  <PACKAGES>...  Packages to uninstall

Options:
  -f, --force    Force uninstall even if depended on
  -v, --verbose  Enable verbose output
```

### stout search

```bash
stout search [OPTIONS] <QUERY>

Arguments:
  <QUERY>  Search query

Options:
  -l, --limit <N>  Maximum results to show (default: 20)
```

### stout info

```bash
stout info <FORMULA>

Arguments:
  <FORMULA>  Formula name
```

### stout list

```bash
stout list [OPTIONS]

Options:
  --requested       Show only explicitly installed packages
  --deps            Show only packages installed as dependencies
  --versions        Show version information
  --source <SRC>    Filter by source: stout, brew, unknown
  --pinned          Show only pinned packages
```

The `--source` flag filters packages by who installed them:
- `stout` - packages installed via stout
- `brew` - packages installed via Homebrew (imported)
- `unknown` - packages with no source recorded

### stout update

```bash
stout update [OPTIONS]

Options:
  -f, --force  Force update even if recently updated
```

### stout sync

Synchronize stout state with Homebrew Cellar and Caskroom:

```bash
stout sync [OPTIONS]

Options:
  -n, --dry-run    Show what would change without modifying state
  -y, --yes        Apply all changes without prompting
  -v, --verbose    Show detailed output
```

stout sync detects drift between stout's tracked packages and what's actually in Homebrew's Cellar/Caskroom:
- Packages in Homebrew but not tracked → added to state
- Packages tracked but not in Homebrew → removed from state
- Version changes → updated in state

### stout import

Import existing Homebrew packages into stout's tracking:

```bash
stout import [OPTIONS] [PACKAGES]...

Arguments:
  [PACKAGES]...  Specific packages to import (default: all untracked)

Options:
  -n, --dry-run     Show what would be imported without modifying state
  --overwrite       Re-import packages already tracked by stout
  -v, --verbose     Show detailed output for each package
```

When importing, stout also relocates Homebrew placeholders (paths like `/opt/homebrew/Cellar/...`) to work with stout's prefix.

### stout upgrade

```bash
stout upgrade [OPTIONS] [PACKAGES]...

Arguments:
  [PACKAGES]...  Specific packages to upgrade (default: all)

Options:
  -n, --dry-run  Show what would be upgraded
```

### stout doctor

```bash
stout doctor [OPTIONS]

Options:
  --fix    Automatically fix issues that can be repaired
```

Checks system health and configuration:
- stout data directory
- Configuration file
- Formula index
- Homebrew prefix and Cellar
- Installed packages state
- Homebrew drift (packages in Cellar/Caskroom not tracked by stout)
- Unrelocated Homebrew placeholders
- Code signatures on all Mach-O binaries (macOS)

Use `--fix` to automatically run sync, relocate unresolved placeholders,
re-sign binaries with invalid signatures, and reinstall corrupted packages.

### stout completions

```bash
stout completions <SHELL>

Arguments:
  <SHELL>  Shell type [bash, zsh, fish, elvish, powershell]
```

### stout outdated

Show packages with available updates:

```bash
stout outdated [OPTIONS] [PACKAGES]...

Arguments:
  [PACKAGES]...  Specific packages to check (default: all)

Options:
  -v, --verbose  Show detailed version info
  --json         Output as JSON
  --greedy       Include auto-updated packages
```

### stout autoremove

Remove packages that were installed as dependencies but are no longer needed:

```bash
stout autoremove [OPTIONS]

Options:
  -n, --dry-run  Show what would be removed without removing
```

### stout deps

Show dependencies for a package:

```bash
stout deps [OPTIONS] <FORMULA>

Arguments:
  <FORMULA>  Formula to show dependencies for

Options:
  --tree              Show dependencies as a tree
  --graph             Output as DOT graph format (pipe to `dot -Tpng`)
  --json              Output as JSON
  -f, --format        Output format (list, tree, graph, json)
  -a, --all           Include all dependency types
  --installed         Only show installed dependencies
  --include-build     Include build dependencies
  --include-test      Include test dependencies
  --include-optional  Include optional dependencies
  -n, --count         Show only the dependency count
```

Example DOT graph output:

```bash
stout deps --graph jq | dot -Tpng -o deps.png
```

### stout uses

Show packages that depend on a given package (reverse dependencies):

```bash
stout uses [OPTIONS] <FORMULA>

Arguments:
  <FORMULA>  Formula to find dependents of

Options:
  --recursive   Show recursive dependents
  --installed   Only show installed dependents
```

### stout why

Show why a package is installed (reverse dependency chain):

```bash
stout why [OPTIONS] <FORMULA>

Arguments:
  <FORMULA>  Formula to find the installation reason for

Options:
  --json       Output as JSON
  -a, --all    Show all dependency paths (not just shortest)
```

Example output:

```
jq is installed because:

● ripgrep (requested)
  └─▶ oniguruma depends on
      └─▶ jq
```

### stout history

Show package version history:

```bash
stout history [OPTIONS] [FORMULA]

Arguments:
  [FORMULA]  Formula to show history for (omit for all packages)

Options:
  --json       Output as JSON
  -n, --limit  Show only the last N entries
```

### stout rollback

Rollback a package to a previous version:

```bash
stout rollback [OPTIONS] <FORMULA>

Arguments:
  <FORMULA>  Formula to rollback

Options:
  -v, --version  Rollback to a specific version (default: previous)
  -n, --dry-run  Show what would be done
```

### stout switch

Switch between installed versions of a package:

```bash
stout switch [OPTIONS] <FORMULA> <VERSION>

Arguments:
  <FORMULA>  Formula to switch
  <VERSION>  Version to switch to

Options:
  -n, --dry-run  Show what would be done
```

### stout home

Open a package's homepage in your default browser:

```bash
stout home <FORMULA>

Arguments:
  <FORMULA>  Formula whose homepage to open
```

### stout pin

Pin a package to prevent it from being upgraded:

```bash
stout pin <FORMULA>

Arguments:
  <FORMULA>  Formula to pin
```

### stout unpin

Unpin a package to allow it to be upgraded:

```bash
stout unpin <FORMULA>

Arguments:
  <FORMULA>  Formula to unpin
```

### stout link

Create symlinks for a package without reinstalling:

```bash
stout link [OPTIONS] <FORMULA>

Arguments:
  <FORMULA>  Formula to link

Options:
  -f, --force      Overwrite existing files
  --overwrite      Synonym for --force
```

### stout unlink

Remove symlinks for a package without uninstalling:

```bash
stout unlink <FORMULA>

Arguments:
  <FORMULA>  Formula to unlink
```

### stout reinstall

Uninstall and reinstall a package:

```bash
stout reinstall [OPTIONS] <FORMULAS>...

Arguments:
  <FORMULAS>...  Formulas to reinstall

Options:
  -s, --build-from-source  Build from source instead of using bottles
  --keep-bottles           Keep downloaded bottles after installation
```

### stout cleanup

Remove old downloads and cache files:

```bash
stout cleanup [OPTIONS] [FORMULAS]...

Arguments:
  [FORMULAS]...  Specific formulas to clean up (default: all)

Options:
  --prune=<DAYS>   Remove downloads older than DAYS (default: 120)
  -s, --scrub      Scrub the cache, including downloads for latest versions
  -n, --dry-run    Show what would be removed without removing
  --prune-prefix   Remove old versions from the Cellar
```

### stout config

Display stout configuration and system information:

```bash
stout config
```

Shows: version, paths, index URL, CPU/OS info, and Rust version.

### stout services

Manage background services for installed packages:

```bash
stout services [COMMAND]

Subcommands:
  list              List all managed services (default)
  start <service>   Start a service
  stop <service>    Stop a service
  restart <service> Restart a service
  run <service>     Run a service (foreground, not registered)
  info <service>    Show service information
  cleanup           Clean up unused services
```

### stout tap

Manage custom formula repositories:

```bash
stout tap [OPTIONS] [TAP]

Arguments:
  [TAP]  Tap to add (e.g., homebrew/cask)

Options:
  -r, --remove  Remove a tap instead of adding
```

### stout lock

Manage lockfiles for reproducible environments:

```bash
stout lock [COMMAND]

Subcommands:
  create            Create a lockfile from currently installed packages
  install           Install packages from a lockfile
  diff              Show differences between lockfile and installed packages
```

## Cask Commands (Applications)

stout can also manage applications (casks) on macOS and Linux. Casks are packaged macOS applications (DMG, PKG, ZIP) or Linux apps (AppImage, Flatpak). All cask operations use `--cask` on the top-level commands.

### Installing Applications

```bash
# Install (auto-detected as cask)
stout install firefox

# Explicitly install as cask
stout install --cask firefox

# Install with options
stout install --cask --no-verify firefox

# Custom application directory
stout install --cask --appdir ~/Apps firefox
```

### Uninstalling Applications

```bash
# Uninstall
stout uninstall --cask firefox

# Remove with thorough cleanup (preferences, caches)
stout uninstall --cask --zap firefox
```

### Searching for Applications

```bash
# Search casks only
stout search --cask browser

# Search both formulas and casks (default)
stout search browser
```

### Application Info

```bash
# Show cask info
stout info --cask visual-studio-code
```

### Listing Applications

```bash
# List installed casks
stout list --cask

# List with versions
stout list --cask --versions

# List both formulas and casks (default)
stout list
```

### Checking for Updates

```bash
# Check both formulas and casks (default)
stout outdated

# Check casks only
stout outdated --cask

# Check formulas only
stout outdated --formula
```

### Upgrading Applications

```bash
# Upgrade all (formulas + casks)
stout upgrade

# Upgrade casks only
stout upgrade --cask

# Upgrade specific cask
stout upgrade firefox
```

### Cask Examples

```bash
# Install popular applications
stout install visual-studio-code firefox slack discord

# View application details
stout info --cask visual-studio-code

# List installed applications with versions
stout list --cask --versions

# Check for updates
stout outdated --cask

# Upgrade all applications
stout upgrade --cask

# Uninstall with thorough cleanup
stout uninstall --cask --zap discord
```

> **Note**: `stout cask <command>` is deprecated. Use `stout <command> --cask` instead.

### Linux Application Support

On Linux, stout supports AppImage and Flatpak formats:

```bash
# AppImage installation
# Apps are installed to ~/.local/share/stout/appimages/
# Symlinks are created in ~/.local/bin/

# Flatpak support (if installed)
# Uses user-level flatpak installation

# Desktop entries are created in ~/.local/share/applications/
```

## Bundle Commands (Brewfile)

stout supports Homebrew's Brewfile format for declaring system packages.

### stout bundle

Install packages from Brewfile (default subcommand):

```bash
stout bundle [OPTIONS]

Options:
  -f, --file <FILE>  Path to Brewfile (default: ./Brewfile)
  --dry-run          Show what would be installed
  --force            Force reinstall
  --no-tap           Skip tap entries
  --no-brew          Skip formula entries
  --no-cask          Skip cask entries
```

### stout bundle dump

Generate Brewfile from installed packages:

```bash
stout bundle dump [OPTIONS]

Options:
  -f, --file <FILE>  Output file (default: ./Brewfile)
  --force            Overwrite existing file
  --all              Include dependencies (not just requested)
  --stdout           Output to stdout instead of file
```

### stout bundle check

Check if all Brewfile packages are installed:

```bash
stout bundle check [OPTIONS]

Options:
  -v, --verbose      Show detailed output
```

### stout bundle list

List entries in Brewfile:

```bash
stout bundle list [OPTIONS]

Options:
  --type <TYPE>      Filter by type (tap, brew, cask, mas)
  --json             Output as JSON
```

### stout bundle cleanup

Remove packages not in Brewfile:

```bash
stout bundle cleanup [OPTIONS]

Options:
  --dry-run          Show what would be removed
  --force            Force removal
```

### Brewfile Format

stout supports the standard Homebrew Brewfile format:

```ruby
# Taps
tap "homebrew/cask"
tap "homebrew/cask-fonts"

# Formulas
brew "jq"
brew "ripgrep"
brew "postgresql@15"

# Casks
cask "firefox"
cask "visual-studio-code"

# Mac App Store (requires mas)
mas "Xcode", id: 497799835
```

## Snapshot Commands

Snapshots allow you to save and restore the current state of installed packages.

### stout snapshot create

Create a new snapshot:

```bash
stout snapshot create <NAME> [OPTIONS]

Arguments:
  <NAME>  Name for the snapshot

Options:
  -d, --description <DESC>  Optional description
  -f, --force               Overwrite if exists
```

### stout snapshot list

List all snapshots:

```bash
stout snapshot list [OPTIONS]

Options:
  --json             Output as JSON
```

### stout snapshot show

Show snapshot details:

```bash
stout snapshot show <NAME> [OPTIONS]

Arguments:
  <NAME>  Snapshot name

Options:
  --json             Output as JSON
```

### stout snapshot restore

Restore a snapshot:

```bash
stout snapshot restore <NAME> [OPTIONS]

Arguments:
  <NAME>  Snapshot name

Options:
  --dry-run          Show what would be installed
  -f, --force        Force install
```

### stout snapshot delete

Delete a snapshot:

```bash
stout snapshot delete <NAME> [OPTIONS]

Arguments:
  <NAME>  Snapshot name

Options:
  -f, --force        Don't ask for confirmation
```

### stout snapshot export/import

Export and import snapshots:

```bash
# Export to stdout
stout snapshot export mysetup > backup.json

# Import from stdin
cat backup.json | stout snapshot import
```

### Snapshot Examples

```bash
# Create a snapshot before major changes
stout snapshot create before-update --description "Before system update"

# List snapshots
stout snapshot list

# Preview what would be restored
stout snapshot restore before-update --dry-run

# Actually restore
stout snapshot restore before-update

# Export for backup
stout snapshot export before-update > ~/backups/stout-snapshot.json
```

## Advanced Usage

### Environment Variables

```bash
# Set log level
RUST_LOG=debug stout search json

# Override config location
STOUT_CONFIG=/path/to/config.toml stout update
```

### Using with Existing Homebrew

stout is designed to coexist with Homebrew:

```bash
# Packages installed by brew are visible to stout
brew install wget
stout list  # Shows wget

# Packages installed by stout are visible to brew
stout install jq
brew list  # Shows jq
```

### Cache Management

stout caches downloaded bottles and formula data:

```bash
# Cache location
~/.stout/downloads/         # Downloaded bottles
~/.stout/formulas/          # Formula JSON files

# Clean up old downloads (>120 days) using cleanup command
stout cleanup

# Clean downloads older than 30 days
stout cleanup --prune=30

# Remove all cached downloads
stout cleanup --scrub

# Preview what would be removed
stout cleanup --dry-run

# Manual cache clearing
rm -rf ~/.stout/downloads/*
rm -rf ~/.stout/formulas/*
```

### Offline Usage

Once you've downloaded the index, many commands work offline:

```bash
# These work offline:
stout search json
stout list
stout doctor

# These require network:
stout update
stout info <pkg>  # If not cached
stout install <pkg>
```

## Examples

### Install a Development Environment

```bash
# Update index first
stout update

# Install common dev tools
stout install git gh jq yq ripgrep fd bat eza

# Verify installation
stout list
```

### Search and Explore

```bash
# Find JSON-related tools
stout search json

# Find packages with "vim" in name/description
stout search vim

# Get details on an interesting package
stout info neovim
```

### Clean Up

```bash
# See what's installed
stout list

# Check for outdated packages
stout outdated

# Remove packages you don't need
stout uninstall package1 package2

# Remove orphaned dependencies
stout autoremove

# Clean up old downloads (older than 120 days)
stout cleanup

# Clean all cached downloads
stout cleanup --scrub
```

### Manage Dependencies

```bash
# Show what a package depends on
stout deps jq

# Show dependencies as a tree
stout deps jq --tree

# Show all dependency types (including build/test)
stout deps jq --all

# Output as DOT graph (for visualization)
stout deps jq --graph | dot -Tpng -o jq-deps.png

# Output as JSON (for scripting)
stout deps jq --json

# Find what depends on a package
stout uses openssl

# Find installed packages that depend on openssl
stout uses openssl --installed

# Find why a package is installed
stout why oniguruma
```

### Version History & Rollback

```bash
# View package history
stout history jq

# View history for all packages
stout history

# View only the last 5 entries
stout history jq -n 5

# Rollback to previous version
stout rollback jq

# Rollback to specific version
stout rollback jq --version 1.6

# Preview rollback without making changes
stout rollback jq --dry-run

# Switch between installed versions (if multiple in Cellar)
stout switch jq 1.7

# Preview switch
stout switch jq 1.6 --dry-run
```

### Pin Packages

```bash
# Prevent a package from being upgraded
stout pin postgresql@15

# See pinned packages
stout list --pinned

# Allow upgrades again
stout unpin postgresql@15
```

### Service Management

```bash
# List services
stout services list

# Start a service
stout services start postgresql

# Stop a service
stout services stop postgresql

# View service info
stout services info postgresql
```

### Security Audit

```bash
# Scan all installed packages for vulnerabilities
stout audit

# Scan specific packages
stout audit jq openssl

# Update vulnerability database before scanning
stout audit --update

# Output as JSON
stout audit --format json

# Only show high/critical severity
stout audit --severity high

# Fail if vulnerabilities found at severity threshold
stout audit --fail-on critical
```

## Audit Commands (Vulnerability Scanning)

stout can scan installed packages for known security vulnerabilities using an offline vulnerability database.

### stout audit

Scan packages for vulnerabilities:

```bash
stout audit [OPTIONS] [PACKAGES]...

Arguments:
  [PACKAGES]...  Packages to audit (default: all installed)

Options:
  --update            Update vulnerability database before scanning
  -f, --format <FMT>  Output format: text (default), json
  --severity <SEV>    Minimum severity to report: low, medium, high, critical
  --fail-on <SEV>     Exit with error if vulnerabilities >= severity found
  --show-unmapped     Show packages without vulnerability data
```

### Audit Examples

```bash
# Full audit of all installed packages
stout audit

# Audit specific packages
stout audit openssl curl wget

# Update database and audit
stout audit --update

# CI/CD usage - fail on high+ severity
stout audit --fail-on high

# Get machine-readable output
stout audit --format json > vulnerabilities.json

# Only show critical issues
stout audit --severity critical

# See which packages have no vulnerability data
stout audit --show-unmapped
```

### Audit Output

Example text output:

```
Auditing 45 packages for vulnerabilities...

CRITICAL CVE-2024-1234 in openssl@3 (3.0.12)
  A critical vulnerability in TLS handshake...
  Fix: 3.0.13
  More info: https://nvd.nist.gov/vuln/detail/CVE-2024-1234

HIGH CVE-2024-5678 in curl (8.4.0)
  Remote code execution via malformed URL...
  Fix: 8.5.0
  More info: https://curl.se/docs/CVE-2024-5678.html

Summary
  1 critical
  1 high
  0 medium
  0 low

  2 total vulnerabilities in 2 packages
```

### How It Works

stout uses a pre-built vulnerability database that maps Homebrew formulas to known CVEs:

1. **Database sync**: `scripts/sync_vulns.py` fetches vulnerability data from OSV (Open Source Vulnerabilities)
2. **Mapping**: Formulas are mapped to their upstream package ecosystems (npm, PyPI, OSS-Fuzz, etc.)
3. **Version matching**: Installed versions are checked against affected version ranges
4. **Reporting**: Findings are sorted by severity

The vulnerability database is updated periodically and downloaded on first use or with `--update`.

## Mirror Commands (Offline Mode)

stout supports creating and using offline mirrors for air-gapped environments.

### stout mirror create

Create a new offline mirror with specified packages:

```bash
stout mirror create <OUTPUT_DIR> [OPTIONS] <PACKAGES>...

Arguments:
  <OUTPUT_DIR>   Output directory for the mirror
  <PACKAGES>...  Packages to include in the mirror

Options:
  --all-installed        Include all installed packages
  --from-brewfile <FILE> Create from Brewfile
  --cask <CASK>         Include cask (can be repeated)
  --platforms <PLAT>    Target platforms (default: current)
  --all-platforms       Include all platforms (warning: large)
  --no-deps             Skip dependency resolution
  --dry-run             Show what would be downloaded
```

### stout mirror serve

Serve a mirror via HTTP:

```bash
stout mirror serve <PATH> [OPTIONS]

Arguments:
  <PATH>  Path to the mirror directory

Options:
  -p, --port <PORT>  Port to listen on (default: 8080)
  --bind <ADDR>      Address to bind to (default: 0.0.0.0)
  --log-access       Enable access logging
```

### stout mirror info

Show information about a mirror:

```bash
stout mirror info <PATH> [OPTIONS]

Arguments:
  <PATH>  Path to the mirror directory

Options:
  --json  Output as JSON
```

### stout mirror verify

Verify mirror integrity:

```bash
stout mirror verify <PATH> [OPTIONS] [PACKAGES]...

Arguments:
  <PATH>        Path to the mirror directory
  [PACKAGES]... Specific packages to verify (default: all)

Options:
  -v, --verbose  Show verbose output
```

### stout mirror outdated

Check for outdated packages in mirror:

```bash
stout mirror outdated <PATH> [OPTIONS]

Arguments:
  <PATH>  Path to the mirror directory

Options:
  --json  Output as JSON
```

### stout mirror update

Update packages in an existing mirror:

```bash
stout mirror update <PATH> [OPTIONS] [PACKAGES]...

Arguments:
  <PATH>        Path to the mirror directory
  [PACKAGES]... Packages to update (default: all)

Options:
  --from-brewfile <FILE>  Update from Brewfile
  --dry-run               Show what would be updated
```

### Mirror Examples

```bash
# Create a mirror with specific packages
stout mirror create ./mirror jq wget curl

# Create a mirror from all installed packages
stout mirror create ./mirror --all-installed

# Create a mirror for multiple platforms
stout mirror create ./mirror jq --platforms arm64_sonoma,x86_64_linux

# Serve a mirror on the network
stout mirror serve ./mirror --port 9000

# Check mirror for outdated packages
stout mirror outdated ./mirror

# Verify mirror integrity
stout mirror verify ./mirror --verbose
```

### Using a Mirror

Configure stout to use a mirror:

```bash
# One-time override
stout --mirror=http://mirror.internal:8080 install jq

# File-based mirror (USB drive, local mount)
stout --mirror=file:///mnt/usb/stout-mirror install jq

# Configure as default in ~/.stout/config.toml
[mirror]
url = "http://mirror.internal:8080"
fallback = "error"   # error, warn, or silent
verify_checksums = false
```

### Mirror Structure

```
mirror/
├── manifest.json           # Master manifest with checksums
├── formulas/
│   ├── index.db.zst        # Filtered SQLite index
│   ├── data/
│   │   └── <letter>/<name>.json.zst
│   └── bottles/
│       └── <name>-<version>.<platform>.bottle.tar.gz
├── casks/
│   ├── index.db.zst
│   ├── data/
│   └── artifacts/
└── linux-apps/
    ├── index.db.zst
    ├── data/
    └── artifacts/
```

## Developer Tools

stout includes tools for formula development and package creation.

### stout bottle

Create and manage binary packages (bottles):

```bash
stout bottle <SUBCOMMAND>

Subcommands:
  create <PACKAGE>    Create a bottle from an installed package
  info <BOTTLE>       Show information about a bottle file
  verify <BOTTLE>     Verify bottle integrity
```

#### Bottle Examples

```bash
# Create a bottle from an installed package
stout bottle create jq

# Show bottle metadata
stout bottle info jq-1.7.1.arm64_linux.bottle.tar.gz

# Verify bottle integrity
stout bottle verify jq-1.7.1.arm64_linux.bottle.tar.gz
```

### stout create

Create new formulas or casks from a URL:

```bash
stout create [OPTIONS] <URL>

Arguments:
  <URL>  URL to the source archive or application

Options:
  --cask              Create a cask instead of a formula
  --name <NAME>       Override the inferred name
  --output <DIR>      Output directory (default: current directory)
```

#### Create Examples

```bash
# Create a formula from a GitHub release
stout create https://github.com/user/project/archive/v1.0.0.tar.gz

# Create a formula with custom name
stout create --name myapp https://example.com/source.tar.gz

# Create a cask from a DMG
stout create --cask https://example.com/App.dmg
```

### stout test

Run tests on installed packages:

```bash
stout test [OPTIONS] [PACKAGES]...

Arguments:
  [PACKAGES]...  Packages to test (default: all installed)

Options:
  -v, --verbose  Show detailed test output
```

#### Test Examples

```bash
# Test all installed packages
stout test

# Test specific packages
stout test jq wget curl

# Test with verbose output
stout test jq --verbose
```

### stout analytics

Manage opt-in anonymous usage analytics:

```bash
stout analytics <SUBCOMMAND>

Subcommands:
  on      Enable anonymous analytics
  off     Disable analytics (default)
  status  Show current analytics status
  what    Show what data would be collected
```

#### Analytics Examples

```bash
# Check current status
stout analytics status

# Enable analytics
stout analytics on

# Disable analytics
stout analytics off

# See what data is collected
stout analytics what
```

### Build from Source Options

When installing packages from source, you can customize the build:

```bash
stout install <PACKAGE> -s [OPTIONS]

Options:
  -s, --build-from-source  Build from source instead of using bottles
  -j, --jobs <N>           Number of parallel build jobs (default: CPU count)
  --cc <COMPILER>          C compiler to use (e.g., clang, gcc)
  --cxx <COMPILER>         C++ compiler to use (e.g., clang++, g++)
```

#### Build Examples

```bash
# Build from source with 8 parallel jobs
stout install jq -s --jobs=8

# Build with specific compilers
stout install jq -s --cc=clang --cxx=clang++

# Build with GCC
stout install openssl -s --cc=gcc --cxx=g++
```

## Multi-Prefix Support

stout supports multiple installation prefixes for isolated environments.

### stout prefix

Manage multiple installation prefixes:

```bash
stout prefix <SUBCOMMAND>

Subcommands:
  create <PATH>    Create a new prefix
  list             List all known prefixes
  info [PATH]      Show prefix information (default: current prefix)
  default <PATH>   Set the default prefix
  remove <PATH>    Remove a prefix
```

### Prefix Create

Create a new isolated prefix:

```bash
stout prefix create [OPTIONS] <PATH>

Arguments:
  <PATH>  Path for the new prefix

Options:
  -f, --force  Force creation even if directory exists
```

### Prefix Remove

Remove a prefix:

```bash
stout prefix remove [OPTIONS] <PATH>

Arguments:
  <PATH>  Path to the prefix

Options:
  --packages     Also remove all installed packages
  -f, --force    Force removal without confirmation
```

### Using Custom Prefixes

You can use a custom prefix with any command using the `--prefix` flag:

```bash
# Install to a custom prefix
stout --prefix=~/project/.stout install jq python@3.11

# List packages in a custom prefix
stout --prefix=~/project/.stout list

# Upgrade packages in a custom prefix
stout --prefix=~/project/.stout upgrade
```

### Environment Variable

Set the default prefix via environment variable:

```bash
export STOUT_PREFIX=~/project/.stout

# All commands now use the custom prefix
stout install jq    # Installs to ~/project/.stout
stout list          # Lists packages in ~/project/.stout
```

### Prefix Examples

```bash
# Create an isolated prefix for a project
stout prefix create ~/projects/myapp/.stout

# View prefix information
stout prefix info ~/projects/myapp/.stout

# Install packages to the project prefix
stout --prefix=~/projects/myapp/.stout install python@3.11 node@20

# List all known prefixes
stout prefix list

# Set as default prefix
stout prefix default ~/projects/myapp/.stout

# Add to PATH for project
export PATH="$HOME/projects/myapp/.stout/bin:$PATH"

# Remove prefix when no longer needed
stout prefix remove ~/projects/myapp/.stout --packages --force
```

### Prefix Structure

When you create a prefix, the following directory structure is created:

```
~/project/.stout/
├── .stout-prefix       # Marker file
├── Cellar/             # Installed package versions
├── bin/                # Executable symlinks
├── lib/                # Library symlinks
├── include/            # Header symlinks
├── share/              # Shared data symlinks
├── etc/                # Configuration files
└── var/                # Variable data
```

### Use Cases for Multi-Prefix

1. **Project-specific dependencies**: Isolate dependencies per project
2. **Version testing**: Test different package versions without affecting system
3. **CI/CD environments**: Create reproducible build environments
4. **Development sandboxes**: Experiment without risk to main installation