Skip to content

Commit 60c8941

Browse files
committed
feat(cli): integrate validate command with comprehensive options
- Add validate command to CLI with full option support - Include all link type filtering options - Support external link validation with timeout configuration - Provide output formatting options (group by file/type, context, JSON) - Add comprehensive help text with examples and link type descriptions - Configure command-line argument parsing for all validation features The CLI now provides complete access to the broken link validation functionality with intuitive options and detailed help documentation.
1 parent 316c9a4 commit 60c8941

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/cli.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { joinCommand } from './commands/join.js';
77
import { mergeCommand } from './commands/merge.js';
88
import { moveCommand } from './commands/move.js';
99
import { splitCommand } from './commands/split.js';
10+
import { validateCommand } from './commands/validate.js';
1011

1112
const program = new Command();
1213

@@ -125,4 +126,46 @@ program
125126
.option('--json', 'Output results in JSON format')
126127
.action(indexCommand);
127128

129+
program
130+
.command('validate')
131+
.description('Find broken links in markdown files')
132+
.argument('<files...>', 'Markdown files to validate (supports globs like *.md, **/*.md)')
133+
.option(
134+
'--link-types <types>',
135+
'Comma-separated link types to check: internal,external,anchor,image,reference,claude-import'
136+
)
137+
.option('--check-external', 'Enable external HTTP/HTTPS link validation', false)
138+
.option('--external-timeout <ms>', 'Timeout for external link validation (ms)', parseInt, 5000)
139+
.option('--strict-internal', 'Treat missing internal files as errors', true)
140+
.option('--check-claude-imports', 'Validate Claude import paths', true)
141+
.option('--check-circular', 'Check for circular references in file dependencies', false)
142+
.option('--max-depth <number>', 'Maximum depth to traverse subdirectories', parseInt)
143+
.option('--only-broken', 'Show only broken links, not all validation results', true)
144+
.option('--group-by <method>', 'Group results by: file|type', 'file')
145+
.option('--include-context', 'Include line numbers and context in output', false)
146+
.option('-v, --verbose', 'Show detailed output with processing information')
147+
.option('--json', 'Output results in JSON format')
148+
.addHelpText(
149+
'after',
150+
`
151+
Examples:
152+
$ markmv validate docs/**/*.md --check-external --verbose
153+
$ markmv validate README.md --link-types internal,image --include-context
154+
$ markmv validate **/*.md --group-by type --only-broken
155+
$ markmv validate docs/ --check-circular --strict-internal
156+
157+
Link Types:
158+
internal Links to other markdown files
159+
external HTTP/HTTPS URLs
160+
anchor Same-file section links (#heading)
161+
image Image references (local and external)
162+
reference Reference-style links ([text][ref])
163+
claude-import Claude @import syntax (@path/to/file)
164+
165+
Output Options:
166+
--group-by file Group broken links by file (default)
167+
--group-by type Group broken links by link type`
168+
)
169+
.action(validateCommand);
170+
128171
program.parse();

0 commit comments

Comments
 (0)