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
// Copyright 2024 zhlinh and linthis Project Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found at
//
// https://opensource.org/license/MIT
//
// The above copyright notice and this permission
// notice shall be included in all copies or
// substantial portions of the Software.
//! CLI command definitions using clap.
//!
//! This module contains the command-line interface definitions for linthis,
//! including the main CLI struct and all subcommand enums.
use clap::Parser;
use std::path::PathBuf;
/// Main CLI parser for linthis.
#[derive(Parser, Debug)]
#[command(name = "linthis")]
#[command(
author,
version,
about = "A fast, cross-platform multi-language linter and formatter",
disable_version_flag = true
)]
#[non_exhaustive]
pub struct Cli {
/// Print version
#[arg(short = 'v', long = "version", action = clap::ArgAction::Version)]
pub version: (),
/// Files or directories to include (can be specified multiple times)
/// Examples: -i src -i lib, --include ./plugin
#[arg(short = 'i', long = "include")]
pub paths: Vec<PathBuf>,
/// Only run lint checks, no formatting
#[arg(short = 'c', long)]
pub check_only: bool,
/// Only format files, no lint checking
#[arg(short = 'f', long)]
pub format_only: bool,
/// Checks to run (comma-separated): lint, security, complexity, all
///
/// Overrides the `checks.run` list in config. Default: ["lint"].
/// Examples:
/// --checks lint,security Run lint + security
/// --checks all Run lint + security + complexity
/// --checks security Run only security (no lint)
#[arg(long, value_delimiter = ',')]
pub checks: Option<Vec<String>>,
/// Check only staged files (git cached)
#[arg(short = 's', long)]
pub staged: bool,
/// Check only files changed since a git ref (branch, tag, or commit)
#[arg(long, value_name = "REF")]
pub since: Option<String>,
/// Check only locally modified files (staged + unstaged).
///
/// Covers all files showing `modified:` in `git status` — both staged
/// (index) and unstaged (working tree) changes in tracked files.
/// Requires a git repository.
#[arg(long, short = 'm', alias = "uncommitted")]
pub modified: bool,
/// Ignore cache and force re-checking all files
#[arg(long)]
pub no_cache: bool,
/// Clear the cache before running
#[arg(long)]
pub clear_cache: bool,
/// Specify languages to check (comma-separated: rust,python,typescript)
#[arg(short, long, value_delimiter = ',')]
pub lang: Option<Vec<String>>,
/// Exclude patterns (glob patterns)
#[arg(short, long)]
pub exclude: Option<Vec<String>>,
/// Disable default exclusions (.git, node_modules, target, etc.)
#[arg(long)]
pub no_default_excludes: bool,
/// Disable .gitignore pattern exclusions
#[arg(long)]
pub no_gitignore: bool,
/// Path to configuration file
#[arg(long)]
pub config: Option<std::path::PathBuf>,
/// Initialize a new .linthis/config.toml configuration file
#[arg(long)]
pub init: bool,
/// Generate default config files for all linters/formatters
#[arg(long)]
pub init_configs: bool,
/// Format preset (google, standard, airbnb)
#[arg(long)]
pub preset: Option<String>,
/// Output format: human, json, github-actions
#[arg(short, long, default_value = "human")]
pub output: String,
/// Disable auto-saving results to .linthis/result/
#[arg(long)]
pub no_save_result: bool,
/// Save results to custom file path (instead of default .linthis/result/)
#[arg(long, value_name = "FILE")]
pub output_file: Option<PathBuf>,
/// Maximum number of result files to keep (default: 10, 0 = unlimited)
#[arg(long, default_value = "10")]
pub keep_results: usize,
/// Verbose output
#[arg(long)]
pub verbose: bool,
/// Suppress non-error output
#[arg(short, long)]
pub quiet: bool,
/// Run benchmark comparing ruff vs flake8+black for Python
#[arg(long)]
pub benchmark: bool,
/// Disable tool auto-install (overrides config)
#[arg(long, default_value_t = false)]
pub no_tool_auto_install: bool,
/// Skip loading plugins, use default configuration
#[arg(long)]
pub no_plugin: bool,
/// Use specific plugin(s) directly, bypassing config files
/// Useful for debugging plugins or CI integration
///
/// Formats:
/// --use-plugin https://github.com/org/plugin.git
/// --use-plugin https://github.com/org/plugin.git@v1.0
/// --use-plugin /path/to/local/plugin
/// --use-plugin plugin1,plugin2 (comma-separated)
#[arg(long, value_delimiter = ',')]
pub use_plugin: Option<Vec<String>>,
/// AI auto-fix: check + fix issues automatically (equivalent to --fix --ai -y)
///
/// Shorthand for running AI-powered fix mode without confirmation.
/// Can specify provider with --provider.
#[arg(long)]
pub auto_fix: bool,
/// Enter fix mode after check/format to fix issues
///
/// Can be combined with --ai for AI-powered fixes
#[arg(long)]
pub fix: bool,
/// Use AI for fix suggestions (requires --fix or --auto-fix)
#[arg(long)]
pub ai: bool,
/// AI provider for fix (requires --ai or --auto-fix)
///
/// Options: claude, claude-cli, codebuddy, codebuddy-cli, openai, local, mock
#[arg(long)]
pub provider: Option<String>,
/// Automatically accept all fix suggestions (requires --fix)
///
/// Warning: This will modify files automatically. Use with caution.
#[arg(short = 'y', long = "yes", alias = "accept-all")]
pub accept_all: bool,
/// Hook event: enable compact output format for git hooks
/// Shows summary at top, lists errors with file:line, and provides fix commands
/// Optional value specifies hook type: pre-commit (default), pre-push, commit-msg
#[arg(long = "hook-event", hide = true, value_name = "HOOK_TYPE", num_args = 0..=1, default_missing_value = "pre-commit")]
pub hook_mode: Option<String>,
/// Plugin subcommands (init, list, clean)
#[command(subcommand)]
pub command: Option<Commands>,
}
/// Hook management tools
#[derive(Clone, Debug, PartialEq, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum HookTool {
/// Traditional git hook
Git,
/// Git hook with AI agent fix fallback on failure
GitWithAgent,
/// AI coding agent integration (Claude Code, Cursor, etc.)
Agent,
/// Prek (Rust-based, faster)
Prek,
/// Prek with AI agent fix fallback on failure
PrekWithAgent,
}
impl HookTool {
/// Returns the base tool without the agent fix variant, if applicable
pub fn base_tool(&self) -> &HookTool {
match self {
HookTool::GitWithAgent => &HookTool::Git,
HookTool::PrekWithAgent => &HookTool::Prek,
other => other,
}
}
/// Returns true if this type includes an AI agent fix fallback
pub fn has_agent_fix(&self) -> bool {
matches!(self, HookTool::GitWithAgent | HookTool::PrekWithAgent)
}
/// Get the CLI string representation (kebab-case, matches clap ValueEnum)
pub fn as_str(&self) -> &'static str {
match self {
HookTool::Git => "git",
HookTool::GitWithAgent => "git-with-agent",
HookTool::Agent => "agent",
HookTool::Prek => "prek",
HookTool::PrekWithAgent => "prek-with-agent",
}
}
}
/// AI agent CLI providers for automatic fix on hook failure (--type *-with-agent)
#[derive(Clone, Debug, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum AgentFixProvider {
/// Anthropic Claude Code CLI (claude -p "prompt")
Claude,
/// OpenAI Codex CLI (codex exec "prompt")
Codex,
/// Google Gemini CLI (gemini -p "prompt")
Gemini,
/// Cursor AI agent CLI (cursor-agent chat "prompt")
Cursor,
/// Factory Droid CLI (droid exec --auto low "prompt")
Droid,
/// Augment Code Auggie CLI (auggie --print "prompt")
Auggie,
/// CodeBuddy CLI (codebuddy -p "prompt")
Codebuddy,
/// OpenClaw agent CLI (openclaw agent --message "prompt")
Openclaw,
}
impl AgentFixProvider {
/// Get the CLI string representation (matches clap ValueEnum, parseable by resolve_agent_fix_provider)
pub fn as_str(&self) -> &'static str {
match self {
AgentFixProvider::Claude => "claude",
AgentFixProvider::Codex => "codex",
AgentFixProvider::Gemini => "gemini",
AgentFixProvider::Cursor => "cursor",
AgentFixProvider::Droid => "droid",
AgentFixProvider::Auggie => "auggie",
AgentFixProvider::Codebuddy => "codebuddy",
AgentFixProvider::Openclaw => "openclaw",
}
}
}
impl std::fmt::Display for AgentFixProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AgentFixProvider::Claude => write!(f, "Claude Code"),
AgentFixProvider::Codex => write!(f, "Codex"),
AgentFixProvider::Gemini => write!(f, "Gemini"),
AgentFixProvider::Cursor => write!(f, "Cursor"),
AgentFixProvider::Droid => write!(f, "Droid"),
AgentFixProvider::Auggie => write!(f, "Auggie"),
AgentFixProvider::Codebuddy => write!(f, "CodeBuddy"),
AgentFixProvider::Openclaw => write!(f, "OpenClaw"),
}
}
}
/// AI coding agent providers (for skills/settings installation, --type agent)
#[derive(Clone, Debug, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum AgentProvider {
/// Claude Code (CLAUDE.md / .claude/)
Claude,
/// OpenAI Codex (AGENTS.md / .codex/)
Codex,
/// Google Gemini (.gemini/)
Gemini,
/// Cursor (.cursor/)
Cursor,
/// Factory Droid (.droid/)
Droid,
/// Augment Code (.augment/)
Auggie,
/// CodeBuddy (.codebuddy/)
Codebuddy,
/// OpenClaw (.openclaw/)
Openclaw,
}
impl std::fmt::Display for AgentProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AgentProvider::Claude => write!(f, "Claude Code"),
AgentProvider::Codex => write!(f, "Codex"),
AgentProvider::Gemini => write!(f, "Gemini"),
AgentProvider::Cursor => write!(f, "Cursor"),
AgentProvider::Droid => write!(f, "Droid"),
AgentProvider::Auggie => write!(f, "Auggie"),
AgentProvider::Codebuddy => write!(f, "CodeBuddy"),
AgentProvider::Openclaw => write!(f, "OpenClaw"),
}
}
}
/// Git hook event types
#[derive(Clone, Debug, Default, PartialEq, clap::ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum HookEvent {
/// Pre-commit hook (runs before commit is created)
#[default]
PreCommit,
/// Pre-push hook (runs before push to remote)
PrePush,
/// Commit-msg hook (validates commit message format)
CommitMsg,
}
impl HookEvent {
/// Get the git hook file name for this event
pub fn hook_filename(&self) -> &'static str {
match self {
HookEvent::PreCommit => "pre-commit",
HookEvent::PrePush => "pre-push",
HookEvent::CommitMsg => "commit-msg",
}
}
/// Get the CLI string representation (kebab-case, matches clap ValueEnum)
pub fn as_str(&self) -> &'static str {
self.hook_filename()
}
/// Get human-readable description
pub fn description(&self) -> &'static str {
match self {
HookEvent::PreCommit => "pre-commit (runs before commit)",
HookEvent::PrePush => "pre-push (runs before push)",
HookEvent::CommitMsg => "commit-msg (validates commit message)",
}
}
}
/// Top-level subcommands
#[derive(clap::Subcommand, Debug)]
pub enum Commands {
/// Plugin management commands
Plugin {
#[command(subcommand)]
action: PluginCommands,
},
/// Configuration management commands
Config {
#[command(subcommand)]
action: ConfigCommands,
},
/// Git hook management commands
Hook {
#[command(subcommand)]
action: HookCommands,
},
/// Cache management commands
Cache {
#[command(subcommand)]
action: CacheCommands,
},
/// Lint check only (no formatting, no security/complexity)
///
/// Run lint checks on files without formatting. Equivalent to `linthis -c --checks lint`.
///
/// Example usage:
/// linthis lint # Lint current directory
/// linthis lint -i src/main.rs # Lint specific file
/// linthis lint -s # Lint staged files
/// linthis lint -m # Lint modified files
Lint {
/// Files or directories to include
#[arg(short = 'i', long = "include")]
paths: Vec<PathBuf>,
/// Lint only staged files (git cached)
#[arg(short = 's', long)]
staged: bool,
/// Lint only locally modified files (staged + unstaged)
#[arg(short = 'm', long, alias = "uncommitted")]
modified: bool,
/// Lint only files changed since a git ref
#[arg(long, value_name = "REF")]
since: Option<String>,
/// Specify languages (comma-separated)
#[arg(short, long, value_delimiter = ',')]
lang: Option<Vec<String>>,
/// Exclude patterns (glob patterns)
#[arg(short, long)]
exclude: Option<Vec<String>>,
/// Disable default exclusions (.git, node_modules, target, etc.)
#[arg(long)]
no_default_excludes: bool,
/// Disable .gitignore pattern exclusions
#[arg(long)]
no_gitignore: bool,
/// Output format: human, json, github-actions
#[arg(short = 'o', long, default_value = "human")]
output: String,
/// Ignore cache
#[arg(long)]
no_cache: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
/// Quiet mode
#[arg(short, long)]
quiet: bool,
},
/// Check only (no formatting), with configurable checks
///
/// Run checks without formatting. Supports --checks to control which checks run.
/// Equivalent to `linthis -c [--checks ...]`.
///
/// Example usage:
/// linthis check # All checks (lint+security+complexity)
/// linthis check -i src/main.rs # Check specific file
/// linthis check -s # Check staged files
/// linthis check --checks lint,security # Only lint + security
/// linthis check --checks lint # Equivalent to `linthis lint`
Check {
/// Files or directories to include
#[arg(short = 'i', long = "include")]
paths: Vec<PathBuf>,
/// Check only staged files (git cached)
#[arg(short = 's', long)]
staged: bool,
/// Check only locally modified files (staged + unstaged)
#[arg(short = 'm', long, alias = "uncommitted")]
modified: bool,
/// Check only files changed since a git ref
#[arg(long, value_name = "REF")]
since: Option<String>,
/// Checks to run (comma-separated): lint, security, complexity, all
#[arg(long, value_delimiter = ',')]
checks: Option<Vec<String>>,
/// Specify languages (comma-separated)
#[arg(short, long, value_delimiter = ',')]
lang: Option<Vec<String>>,
/// Exclude patterns (glob patterns)
#[arg(short, long)]
exclude: Option<Vec<String>>,
/// Disable default exclusions (.git, node_modules, target, etc.)
#[arg(long)]
no_default_excludes: bool,
/// Disable .gitignore pattern exclusions
#[arg(long)]
no_gitignore: bool,
/// Output format: human, json, github-actions
#[arg(short = 'o', long, default_value = "human")]
output: String,
/// Ignore cache
#[arg(long)]
no_cache: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
/// Quiet mode
#[arg(short, long)]
quiet: bool,
},
/// Security vulnerability scanning
///
/// Scan project for security vulnerabilities using SCA (dependency scanning)
/// and/or SAST (source code analysis).
///
/// SCA tools: cargo-audit, npm audit, pip-audit, govulncheck, dependency-check.
/// SAST tools: OpenGrep/Semgrep, Bandit, Gosec, Flawfinder.
///
/// Example usage:
/// linthis security # Run both SCA and SAST
/// linthis security --scan-type sca # Only dependency scanning
/// linthis security --scan-type sast # Only source code analysis
/// linthis security --severity high # Only show high+ severity
/// linthis security --fix # Show fix suggestions
/// linthis security --format json # Output as JSON
/// linthis security --sast-config rules.yml # Custom SAST rules
Security {
/// Path to scan (defaults to current directory)
#[arg(default_value = ".")]
path: PathBuf,
/// Scan type: all (default), sca (dependencies only), sast (source code only)
#[arg(long, default_value = "all")]
scan_type: String,
/// Minimum severity to report (critical, high, medium, low)
#[arg(long, short = 's')]
severity: Option<String>,
/// Include dev dependencies
#[arg(long)]
include_dev: bool,
/// Show fix suggestions
#[arg(long)]
fix: bool,
/// Vulnerability IDs to ignore (can be specified multiple times)
#[arg(long, short = 'i')]
ignore: Option<Vec<String>>,
/// Output format: human, json, sarif
#[arg(short, long, default_value = "human")]
format: String,
/// Generate SBOM (Software Bill of Materials)
#[arg(long)]
sbom: bool,
/// Exit with error if vulnerabilities meet severity threshold
#[arg(long)]
fail_on: Option<String>,
/// Custom SAST rules/config file path
#[arg(long)]
sast_config: Option<PathBuf>,
/// Verbose output
#[arg(long)]
verbose: bool,
},
/// License compliance checking
///
/// Scan project dependencies for license information and check compliance
/// against configurable policies.
///
/// Example usage:
/// linthis license # Scan current directory
/// linthis license --policy strict # Use strict policy
/// linthis license --format json # Output as JSON
/// linthis license --sbom # Generate SBOM
License {
/// Path to scan (defaults to current directory)
#[arg(default_value = ".")]
path: PathBuf,
/// Policy preset: default, strict, permissive
#[arg(long, short = 'p', default_value = "default")]
policy: String,
/// Custom policy file path
#[arg(long)]
policy_file: Option<PathBuf>,
/// Include dev dependencies
#[arg(long)]
include_dev: bool,
/// Output format: human, json, spdx
#[arg(short, long, default_value = "human")]
format: String,
/// Generate SBOM (Software Bill of Materials)
#[arg(long)]
sbom: bool,
/// Exit with error if policy violations found
#[arg(long)]
fail_on_violation: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
},
/// Code complexity analysis
///
/// Analyze code complexity metrics across your codebase including cyclomatic
/// complexity, cognitive complexity, nesting depth, and function length.
///
/// Example usage:
/// linthis complexity # Analyze current directory
/// linthis complexity -s # Analyze staged files
/// linthis complexity -m # Analyze modified files
/// linthis complexity src/ # Analyze specific directory
/// linthis complexity --output html # Generate HTML report
/// linthis complexity --threshold 15 # Custom complexity threshold
Complexity {
/// Path to analyze (defaults to current directory)
#[arg(default_value = ".")]
path: PathBuf,
/// Analyze only staged files (git cached)
#[arg(short = 's', long)]
staged: bool,
/// Analyze only locally modified files (staged + unstaged)
#[arg(short = 'm', long, alias = "uncommitted")]
modified: bool,
/// File patterns to include (glob patterns)
#[arg(long, short = 'i')]
include: Option<Vec<String>>,
/// File patterns to exclude (glob patterns)
#[arg(long, short = 'e')]
exclude: Option<Vec<String>>,
/// Complexity threshold for warnings (cyclomatic)
#[arg(long, short = 't')]
threshold: Option<u32>,
/// Threshold preset: default, strict, lenient
#[arg(long, default_value = "default")]
preset: String,
/// Output format: human, json, markdown, html
#[arg(short = 'o', long = "output", default_value = "human")]
format: String,
/// Include trend analysis from previous runs
#[arg(long)]
with_trends: bool,
/// Number of historical runs for trends (default: 10)
#[arg(short = 'n', long, default_value = "10")]
trend_count: usize,
/// Only show functions exceeding threshold
#[arg(long)]
only_high: bool,
/// Sort output by: cyclomatic, cognitive, lines, name
#[arg(long, default_value = "cyclomatic")]
sort: String,
/// Disable parallel processing
#[arg(long)]
no_parallel: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
},
/// Initialize configuration file
Init {
/// Create global configuration (~/.linthis/config.toml)
#[arg(short, long)]
global: bool,
/// Also install git hook after creating config
#[arg(long)]
with_hook: bool,
/// Force overwrite existing files
#[arg(long)]
force: bool,
},
/// Check tool availability and configuration health
Doctor {
/// Check all languages instead of only detected ones
#[arg(long)]
all: bool,
/// Output format: human, json
#[arg(short, long, default_value = "human")]
output: String,
},
/// Start the Language Server Protocol (LSP) server
///
/// The LSP server provides real-time linting diagnostics to editors
/// like VS Code, Neovim, and other LSP-compatible clients.
///
/// Example usage:
/// linthis lsp # Start in stdio mode (default)
/// linthis lsp --mode tcp # Start in TCP mode on port 9257
/// linthis lsp --use-plugin https://github.com/org/plugin.git
Lsp {
/// Communication mode: stdio (default) or tcp
#[arg(long, default_value = "stdio")]
mode: String,
/// TCP port (only used when mode is tcp)
#[arg(long, default_value = "9257")]
port: u16,
/// Use specific plugin(s) directly, bypassing config files
///
/// Example: --use-plugin https://github.com/zhlinh/linthis-plugin-template
#[arg(long, value_delimiter = ',')]
use_plugin: Option<Vec<String>>,
},
/// Generate reports and analyze lint results
///
/// Generate HTML reports, view statistics, analyze trends over time,
/// and check code consistency across your codebase.
///
/// Example usage:
/// linthis report stats # Show statistics from last run
/// linthis report html # Generate HTML report
/// linthis report html --with-trends # Include trend analysis
/// linthis report trends -n 20 # Analyze last 20 runs
/// linthis report consistency # Check code consistency
Report {
#[command(subcommand)]
action: ReportCommands,
},
/// Validate commit message format (Conventional Commits)
///
/// Accepts either a path to the commit message file (as used by git's
/// commit-msg hook) or the message string directly.
///
/// Example usage:
/// linthis cmsg "feat: add new feature"
/// linthis cmsg "fix(api): handle null response"
/// linthis cmsg .git/COMMIT_EDITMSG
/// linthis cmsg .git/COMMIT_EDITMSG --auto-fix # AI rewrite on failure
Cmsg {
/// Path to commit message file, or the commit message string directly.
msg_or_file: String,
/// Automatically rewrite invalid commit messages using AI
///
/// When the message fails validation, AI rewrites it to conform to
/// Conventional Commits format and writes it back (if source is a file).
#[arg(long)]
auto_fix: bool,
/// AI provider for auto-fix
#[arg(long, requires = "auto_fix")]
provider: Option<String>,
},
/// Watch files for changes and auto-lint
///
/// Monitors directories for file changes and automatically runs lint checks
/// when files are modified. Supports a rich TUI interface or simple stdout mode.
///
/// Example usage:
/// linthis watch # Watch current directory with TUI
/// linthis watch src/ # Watch specific directory
/// linthis watch --no-tui # Watch with simple stdout output
/// linthis watch -c # Watch with check-only mode
/// linthis watch --notify # Enable desktop notifications
Watch {
/// Paths to watch (defaults to current directory)
#[arg(default_value = ".")]
paths: Vec<PathBuf>,
/// Only check, don't format
#[arg(short = 'c', long)]
check_only: bool,
/// Only format, don't check
#[arg(short = 'f', long)]
format_only: bool,
/// Debounce delay in milliseconds
#[arg(long, default_value = "300")]
debounce: u64,
/// Enable desktop notifications
#[arg(long)]
notify: bool,
/// Disable TUI (use simple stdout output)
#[arg(long)]
no_tui: bool,
/// Clear screen before each run
#[arg(long)]
clear: bool,
/// Specify languages to check (comma-separated)
#[arg(short, long, value_delimiter = ',')]
lang: Option<Vec<String>>,
/// Exclude patterns (glob patterns)
#[arg(short, long)]
exclude: Option<Vec<String>>,
/// Verbose output
#[arg(long)]
verbose: bool,
},
/// Format files and manage format backups
///
/// Run formatters on files with automatic backup before changes.
/// Supports undo to restore files to their pre-format state.
///
/// Example usage:
/// linthis format # Format all files
/// linthis format -s # Format staged files
/// linthis format -i src/main.rs # Format specific file
/// linthis format --undo # Undo last format
/// linthis format --list-backups # List available backups
Format {
/// Files or directories to include
#[arg(short = 'i', long = "include")]
paths: Vec<PathBuf>,
/// Format only staged files (git cached)
#[arg(short = 's', long)]
staged: bool,
/// Format only locally modified files (staged + unstaged)
///
/// Covers all files showing `modified:` in `git status` — both staged
/// (index) and unstaged (working tree) changes in tracked files.
#[arg(short = 'm', long, alias = "uncommitted")]
modified: bool,
/// Exclude patterns (glob patterns)
#[arg(short, long)]
exclude: Option<Vec<String>>,
/// Restore files from the last backup (undo previous format)
///
/// Backups are automatically created before each format operation.
/// Use this to revert changes if the format produced unwanted results.
#[arg(long)]
undo: bool,
/// Backup name to restore (use with --undo, defaults to latest)
#[arg(default_value = "last")]
source: String,
/// List available backups
#[arg(long)]
list_backups: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
/// Suppress non-error output
#[arg(short, long)]
quiet: bool,
},
/// Interactive fix mode for reviewing and fixing lint issues
///
/// Review and fix issues one by one, with optional AI-powered suggestions.
/// Supports loading from previous results or running check first.
///
/// Example usage:
/// linthis fix # Load last result, interactive mode
/// linthis fix result.json # Load specific result file
/// linthis fix -c # Run check first, then fix
/// linthis fix --ai # AI-assisted batch fix mode
/// linthis fix --ai -i src/main.rs --line 10 # AI fix for specific location
Fix {
/// Source of lint results: "last" (default) or a result file path
#[arg(default_value = "last")]
source: String,
/// Run lint check first, then enter fix mode
#[arg(short = 'c', long)]
check: bool,
/// Run format only first, then enter fix mode
#[arg(short = 'f', long)]
format_only: bool,
/// AI auto-fix: apply all AI suggestions automatically (equivalent to --ai -y)
#[arg(long = "auto")]
auto_fix: bool,
/// Enable AI-powered fix suggestions
#[arg(long)]
ai: bool,
/// AI provider: claude (default), claude-cli, codebuddy, codebuddy-cli, openai, local, mock
///
/// Priority: CLI > env var (LINTHIS_AI_PROVIDER) > config file ([ai] section) > default
#[arg(long)]
provider: Option<String>,
/// Model name (defaults to provider's default)
#[arg(long)]
model: Option<String>,
/// Maximum suggestions per issue (default: 3)
#[arg(long, default_value = "3")]
max_suggestions: usize,
/// Automatically accept all AI suggestions without confirmation
///
/// Warning: This will modify files automatically. Use with caution.
#[arg(short = 'y', long = "yes", alias = "accept-all")]
accept_all: bool,
/// Number of parallel jobs for AI analysis (default: 4)
///
/// Use -j 4 or --jobs 4 for parallel processing with 4 threads.
/// Use -j 1 for sequential processing.
#[arg(short = 'j', long, default_value = "4", requires = "ai")]
jobs: usize,
/// Target specific file for AI fix (use with --ai)
#[arg(short = 'i', long = "include", requires = "ai")]
file: Option<PathBuf>,
/// Target specific line number (requires -i/--include)
#[arg(long, requires = "file")]
line: Option<u32>,
/// Issue message for context (optional, use with --line)
#[arg(long, requires = "line")]
message: Option<String>,
/// Rule ID for context (optional, use with --line)
#[arg(long, requires = "line")]
rule: Option<String>,
/// Output format for AI mode: human, json, diff
#[arg(short = 'o', long, default_value = "human")]
output: String,
/// Include code context in AI output
#[arg(long)]
with_context: bool,
/// Verbose output
#[arg(long)]
verbose: bool,
/// Suppress non-error output
#[arg(short, long)]
quiet: bool,
/// Restore files from the last backup (undo previous fix)
///
/// Backups are automatically created before each fix operation.
/// Use this to revert changes if the fix produced unwanted results.
#[arg(long)]
undo: bool,
/// List available backups
#[arg(long)]
list_backups: bool,
},
/// AI-powered code review
///
/// Analyze git diffs using AI to find code quality, security, and architecture issues.
/// Supports background execution via pre-push hooks, auto-fix with PR/MR creation,
/// and configurable notifications.
///
/// Example usage:
/// linthis review # Review current branch vs remote
/// linthis review --auto-fix # Review + auto-fix + create PR
/// linthis review -r alice -r bob # Specify reviewers
/// linthis review --base main # Diff against main branch
/// linthis review --background # Run in background
/// linthis review --status # Check background review status
Review {
/// Run review in background (async, non-blocking)
#[arg(long, short = 'b')]
background: bool,
/// Enable AI auto-fix and create PR/MR with fixes
#[arg(long)]
auto_fix: bool,
/// Auto-fix mode: pr, commit, apply (default: apply)
#[arg(long)]
auto_fix_mode: Option<String>,
/// Specify reviewer(s) for PR/MR (repeatable)
#[arg(long = "reviewer", short = 'r')]
reviewers: Option<Vec<String>>,
/// AI provider to use
#[arg(long)]
provider: Option<String>,
/// Base branch/commit for diff comparison
#[arg(long)]
base: Option<String>,
/// HEAD ref to review (default: HEAD)
#[arg(long, default_value = "HEAD")]
head: String,
/// Generate report only, do not create PR/MR
#[arg(long)]
no_pr: bool,
/// Notification channels to use (repeatable)
#[arg(long)]
notify: Option<Vec<String>>,
/// Check status of background reviews
#[arg(long)]
status: bool,
/// Preview auto-fix actions without pushing or creating PR
#[arg(long)]
dry_run: bool,
/// Remove old review artifacts
#[arg(long)]
clean: bool,
/// Output format: markdown or json
#[arg(short, long, default_value = "markdown")]
output: String,
},
/// Backup management: create, list, and show backups
Backup {
#[command(subcommand)]
action: BackupCommands,
},
/// Undo the last operation (format, fix, or hook fix)
///
/// Restores files from the most recent matching backup.
/// Use a filter to target specific operation types:
/// linthis undo # undo last operation (any type)
/// linthis undo format # undo last format
/// linthis undo fix # undo last fix (including AI fix)
/// linthis undo hook # undo last hook-agent-fix
/// linthis undo <id> # undo specific backup by timestamp
Undo {
/// Filter: "last" (default), "format", "fix", "hook", or a backup timestamp
#[arg(default_value = "last")]
filter: String,
/// List available backups instead of restoring
#[arg(long)]
list: bool,
},
/// Re-apply changes that were undone by `linthis undo`
Redo,
}
/// Backup subcommands
#[derive(clap::Subcommand, Debug)]
pub enum BackupCommands {
/// Create a backup of specified files
Create {
/// Files to backup
files: Vec<std::path::PathBuf>,
/// Description of the backup
#[arg(short, long, default_value = "manual")]
description: String,
},
/// List available backups
List,
/// Show details of a specific backup
Show {
/// Backup timestamp or "last"
#[arg(default_value = "last")]
id: String,
},
/// Show diff between backup and current files
Diff {
/// Backup timestamp or "last"
#[arg(default_value = "last")]
id: String,
},
}
/// Hook subcommands
#[derive(clap::Subcommand, Debug)]
pub enum HookCommands {
/// Install git hooks or AI agent skills
///
/// Hook types (--type):
///
/// {git,prek} Traditional shell hook
///
/// {git,prek}-with-agent Shell hook + AI auto-fix on failure
///
/// agent AI coding agent lint skill (Claude, Cursor, etc.)
Install {
/// Hook tool(s) to use — comma-separated or repeated
/// (e.g. --type git,agent or --type git --type agent)
///
/// Shell hooks: git, prek
/// Shell hook + AI fix: git-with-agent, prek-with-agent
/// AI agent skills: agent
///
/// If both x and x-with-agent are given, x-with-agent wins.
/// If omitted, an interactive menu is shown (or git when -y is set).
#[arg(long = "type", value_name = "TYPE", value_delimiter = ',', num_args = 0..)]
hook_types: Vec<HookTool>,
/// Git hook event(s) — comma-separated or repeated
/// (e.g. --event pre-commit,pre-push)
///
/// If omitted, an interactive menu is shown (or pre-commit when -y is set,
/// or all three events when --type agent is the only type with -y).
#[arg(long = "event", value_name = "EVENT", value_delimiter = ',', num_args = 0..)]
hook_events: Vec<HookEvent>,
/// Force overwrite existing hook
#[arg(long)]
force: bool,
/// Non-interactive mode (use defaults, no prompts)
#[arg(short = 'y', long)]
yes: bool,
/// Install globally:
///
/// - For --type agent: installs skills into user home directory (~/.claude/, ~/.cursor/, etc.)
///
/// - For other types: installs hook into ~/.config/git/hooks/ and sets core.hooksPath
/// (Strategy B: local hook takes priority; global runs linthis only when local has no linthis)
#[arg(short = 'g', long)]
global: bool,
/// AI provider: claude, codex, gemini, cursor, droid, auggie, codebuddy
///
/// For --type agent: installs skill/settings files for the provider
///
/// For --type *-with-agent: uses the provider's headless CLI to auto-fix
#[arg(long)]
provider: Option<String>,
/// Extra arguments for the linthis command in the hook script
///
/// Default: "-c -f" (check + format).
/// Examples: "-c" (check only), "-f" (format only),
/// "-c -f --auto-fix --provider claude" (AI auto-fix)
#[arg(long, allow_hyphen_values = true)]
args: Option<String>,
/// Extra arguments passed to the AI agent CLI (e.g. "--model opus")
#[arg(long, allow_hyphen_values = true)]
provider_args: Option<String>,
},
/// Uninstall git hook
Uninstall {
/// Hook tool(s) to uninstall — comma-separated or repeated
/// (e.g. --type git,agent or --type git --type agent)
#[arg(long = "type", value_name = "TYPE", value_delimiter = ',', num_args = 0..)]
hook_types: Vec<HookTool>,
/// Git hook event(s) to uninstall — comma-separated or repeated
/// (e.g. --event pre-commit,pre-push)
#[arg(long = "event", value_name = "EVENT", value_delimiter = ',', num_args = 0..)]
hook_events: Vec<HookEvent>,
/// Uninstall all hooks (all types × all events)
#[arg(long, conflicts_with_all = ["all_types", "all_events"])]
all: bool,
/// Uninstall all hook types for the specified --event(s).
/// Requires at least one --event. Equivalent to specifying every --type.
#[arg(long, conflicts_with = "all", requires = "hook_events")]
all_types: bool,
/// Uninstall all hook events for the specified --type(s).
/// Requires at least one --type. Equivalent to specifying every --event.
#[arg(long, conflicts_with = "all", requires = "hook_types")]
all_events: bool,
/// Non-interactive mode
#[arg(short = 'y', long)]
yes: bool,
/// Uninstall from global location:
/// - For --type agent: removes skills from user home directory
/// - For other types: removes hook from ~/.config/git/hooks/ and unsets core.hooksPath if empty
#[arg(short = 'g', long)]
global: bool,
},
/// Show git hook status
Status,
/// List all installed hooks (git, agent, with-agent) and their providers
List {
/// Include global hooks
#[arg(short = 'g', long)]
global: bool,
},
/// Check for hook conflicts
Check,
/// Validate commit message format (used by commit-msg hook)
///
/// Deprecated: use `linthis cmsg` instead.
#[command(hide = true)]
CommitMsgCheck {
/// Path to commit message file, or the commit message string directly.
msg_or_file: String,
},
/// Execute hook logic at runtime (used internally by thin wrapper scripts)
///
/// This command is invoked by the thin wrapper scripts installed in .git/hooks/.
/// It generates and executes the full hook script dynamically from the current
/// linthis binary, so hook logic is always up-to-date after binary upgrades.
#[command(hide = true)]
Run {
/// Git hook event
#[arg(long)]
event: HookEvent,
/// Hook tool type
#[arg(long = "type", value_name = "TYPE")]
hook_type: HookTool,
/// AI provider (for *-with-agent types)
#[arg(long)]
provider: Option<String>,
/// Extra arguments passed to the AI agent CLI
#[arg(long, allow_hyphen_values = true)]
provider_args: Option<String>,
/// Run against global hooks
#[arg(short = 'g', long)]
global: bool,
/// Passthrough arguments from the hook invocation (e.g. commit message file path)
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
hook_args: Vec<String>,
},
/// Re-sync installed hooks (thin wrapper scripts + agent skill components)
///
/// Re-generates hook scripts and refreshes agent skills (CLAUDE.md, skill files, etc.)
/// from the current linthis binary. Useful after upgrading linthis or plugins.
///
/// Reads installed hook parameters from ~/.linthis/installed-hooks.toml.
Sync {
/// Re-sync global hooks instead of local project hooks
#[arg(short = 'g', long)]
global: bool,
/// Non-interactive (skip confirmation prompts)
#[arg(short = 'y', long)]
yes: bool,
},
}
/// Plugin subcommands
#[derive(clap::Subcommand, Debug)]
pub enum PluginCommands {
/// Create a new plugin from template
///
/// Creates a plugin directory with example configs for supported languages.
/// The generated plugin includes linting and formatting configs that can be
/// customized for your team's coding standards.
///
/// Example:
/// linthis plugin new my-company-standards
/// linthis plugin new my-plugin --languages rust,python,go
New {
/// Plugin name (will be used as directory name)
name: String,
/// Only include specific languages (comma-separated)
/// Example: --languages rust,python,go
#[arg(short, long, value_delimiter = ',')]
languages: Option<Vec<String>>,
/// Overwrite existing directory
#[arg(long)]
force: bool,
},
/// List configured or cached plugins
List {
/// Show detailed information
#[arg(long)]
verbose: bool,
/// List global plugins (~/.linthis/config.toml)
#[arg(short, long)]
global: bool,
/// List cached (downloaded) plugins instead of configured
#[arg(short, long)]
cached: bool,
},
/// Clean cached plugins
Clean {
/// Remove all cached plugins
#[arg(long)]
all: bool,
},
/// Sync (download/update) configured plugins to latest version
Sync {
/// Sync global plugins (~/.linthis/config.toml)
#[arg(short, long)]
global: bool,
/// Plugin alias to sync (syncs all if omitted)
#[arg(value_name = "ALIAS")]
plugin: Option<String>,
},
/// Validate a plugin manifest
Validate {
/// Path to plugin directory
path: PathBuf,
},
/// Add a plugin to configuration
Add {
/// Plugin alias (unique name for the plugin)
alias: String,
/// Plugin Git repository URL
url: String,
/// Git reference (branch, tag, or commit)
#[arg(long = "ref")]
git_ref: Option<String>,
/// Add to global configuration (~/.linthis/config.toml)
#[arg(short, long)]
global: bool,
},
/// Remove a plugin from configuration (by alias)
Remove {
/// Plugin alias to remove
alias: String,
/// Remove from global configuration
#[arg(short, long)]
global: bool,
},
/// Apply (copy) plugin configs to current project
Apply {
/// Plugin alias to apply configs from
alias: Option<String>,
/// Apply configs from global plugins
#[arg(short, long)]
global: bool,
/// Languages to apply configs for (e.g., cpp, oc, swift)
#[arg(short, long)]
language: Option<Vec<String>>,
},
}
/// Config subcommands
#[derive(clap::Subcommand, Debug)]
pub enum ConfigCommands {
/// Add value to an array field (includes, excludes, languages)
Add {
/// Field name (includes, excludes, languages)
field: ConfigField,
/// Value to add
value: String,
/// Modify global configuration (~/.linthis/config.toml)
#[arg(short, long)]
global: bool,
},
/// Remove value from an array field
Remove {
/// Field name (includes, excludes, languages)
field: ConfigField,
/// Value to remove
value: String,
/// Modify global configuration
#[arg(short, long)]
global: bool,
},
/// Clear all values from an array field
Clear {
/// Field name (includes, excludes, languages)
field: ConfigField,
/// Modify global configuration
#[arg(short, long)]
global: bool,
},
/// Set a scalar field value (max_complexity, preset, verbose)
Set {
/// Field name (max_complexity, preset, verbose)
field: String,
/// Field value
value: String,
/// Modify global configuration
#[arg(short, long)]
global: bool,
},
/// Unset a scalar field (restore to default)
Unset {
/// Field name
field: String,
/// Modify global configuration
#[arg(short, long)]
global: bool,
},
/// Get the value of a field
Get {
/// Field name
field: String,
/// Get from global configuration
#[arg(short, long)]
global: bool,
},
/// List all configuration values
List {
/// Show detailed information (including source)
#[arg(long)]
verbose: bool,
/// List global configuration
#[arg(short, long)]
global: bool,
},
/// Migrate existing linter/formatter configs to linthis format
Migrate {
/// Only migrate from specific tool (eslint, prettier, black, isort)
#[arg(long = "from")]
from_tool: Option<String>,
/// Preview changes without applying them
#[arg(long)]
dry_run: bool,
/// Create backup of original config files
#[arg(long)]
backup: bool,
/// Show detailed output
#[arg(long)]
verbose: bool,
},
}
/// Configuration field types for CLI operations
#[derive(clap::ValueEnum, Clone, Debug)]
#[allow(non_camel_case_types)]
pub enum ConfigField {
#[value(name = "includes")]
Includes,
#[value(name = "excludes")]
Excludes,
#[value(name = "languages")]
Languages,
}
impl ConfigField {
/// Get the string representation of the field name
pub fn as_str(&self) -> &'static str {
match self {
ConfigField::Includes => "includes",
ConfigField::Excludes => "excludes",
ConfigField::Languages => "languages",
}
}
}
/// Cache subcommands
#[derive(clap::Subcommand, Debug)]
pub enum CacheCommands {
/// Clear the lint cache
Clear,
/// Show cache statistics
Status,
}
/// Report subcommands
#[derive(clap::Subcommand, Debug)]
pub enum ReportCommands {
/// Show lint results (default subcommand)
///
/// Display saved lint results in human, JSON, or HTML format.
///
/// Example usage:
/// linthis report show # Human-readable (default)
/// linthis report show -f json # Raw JSON output
/// linthis report show -f html # Generate HTML report
/// linthis report show -f html --open # Generate HTML and open in browser
/// linthis report show -f html -o r.html # Generate HTML to specific file
/// linthis report show -n 10 # Limit to 10 issues
/// linthis report show -s error # Only errors
/// linthis report show -s all # All severities including info
Show {
/// Source of lint results: "last" (default) or a result file path
#[arg(default_value = "last")]
source: String,
/// Output format: human (default), json, html
#[arg(short, long, default_value = "human")]
format: String,
/// Severity filter: error, warning, info, all, or comma-separated (default: error,warning)
#[arg(short, long, default_value = "error,warning")]
severity: String,
/// Output file path (for html: default .linthis/reports/report-{timestamp}.html)
#[arg(short, long)]
output: Option<PathBuf>,
/// Open HTML report in browser (only with -f html)
#[arg(long)]
open: bool,
/// Limit number of issues to display (0 = unlimited, human/json only)
#[arg(short = 'n', long, default_value = "0")]
limit: usize,
/// Compact format: show only file:line message without code context
#[arg(long)]
compact: bool,
/// Include historical trend analysis (html format only)
#[arg(long)]
with_trends: bool,
/// Number of historical runs for trends (default: 10)
#[arg(long, default_value = "10")]
trend_count: usize,
},
/// Show statistics from lint results
Stats {
/// Source of lint results: "last" (default) or a file path
#[arg(default_value = "last")]
source: String,
/// Output format: human (default), json
#[arg(short, long, default_value = "human")]
format: String,
},
/// Analyze code quality trends over time
Trends {
/// Number of historical runs to analyze (default: 10)
#[arg(short = 'n', long, default_value = "10")]
count: usize,
/// Output format: human (default), json
#[arg(short, long, default_value = "human")]
format: String,
},
/// Analyze team code style consistency
Consistency {
/// Source of lint results: "last" (default) or a file path
#[arg(default_value = "last")]
source: String,
/// Output format: human (default), json
#[arg(short, long, default_value = "human")]
format: String,
},
}