-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
44 lines (37 loc) · 1.07 KB
/
index.ts
File metadata and controls
44 lines (37 loc) · 1.07 KB
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
#!/usr/bin/env node
import { program } from 'commander';
import { report, validate } from './src';
program
.name('spec-score')
.description('CLI to validate OpenAPI schemas and generate reports')
.version('0.1.0');
program
.command('validate')
.description('Validate an OpenAPI schema file or url link')
.argument('<file>', 'Path to the OpenAPI schema file (yaml or json) or URL')
.action(validate);
program
.command('report')
.description('Generate a report for an OpenAPI schema file or url link')
.argument('<file>', 'Path to the OpenAPI schema file (yaml or json) or URL')
.option(
'-f, --format <format>',
'Output format: console, markdown, html',
'console',
)
.option(
'-o, --output <file>',
'Output file path (for markdown, html formats)',
'report.md',
)
.action(report);
program.parse(process.argv);
// gracefully handle shutdown
process.on('SIGINT', () => {
console.log('\nGracefully shutting down...');
process.exit();
});
// Show help if no command provided
if (!process.argv.slice(2).length) {
program.outputHelp();
}