1 | #!/usr/bin/env node
|
2 |
|
3 | const program = require('commander');
|
4 | const cli = require('../lib/cli-reporter');
|
5 | const pkg = require('../package.json');
|
6 |
|
7 | function list(val) {
|
8 | return val.split(',');
|
9 | }
|
10 |
|
11 |
|
12 | program
|
13 | .description('Report todos and fixmes from json files or stream')
|
14 | .version(pkg.version)
|
15 | .usage('[options] <file ...>')
|
16 | .option('-i, --ignore <patterns>', 'add ignore patterns', list, [])
|
17 | .option('-r, --reporter [reporter]', 'use reporter (table|json|xml|markdown|vscode|raw) (default: table)', 'table')
|
18 | .option('-x, --exit-nicely', 'exit with exit code 0 even if todos/fixmes are found', false)
|
19 | .on('--help', function() {
|
20 | console.log(' Examples:');
|
21 | console.log('');
|
22 | console.log(' # Report todos from a specific file');
|
23 | console.log(' $ leasot-reporter index.json');
|
24 | console.log('');
|
25 | console.log(' # Report todos from a glob pattern');
|
26 | console.log(' $ leasot-reporter **/*.json');
|
27 | console.log('');
|
28 | console.log(' # Use the json reporter');
|
29 | console.log(' $ leasot-reporter --reporter json index.json');
|
30 | console.log('');
|
31 | console.log(' # Report from a json stream');
|
32 | console.log(' $ cat index.json | leasot-reporter --reporter xml');
|
33 | console.log('');
|
34 | console.log(' # Report from leasot parsing and filter todos using `jq`');
|
35 | console.log(
|
36 | ' $ leasot tests/**/*.styl --reporter json | jq \'map(select(.kind == "TODO"))\' | leasot-reporter'
|
37 | );
|
38 | console.log('');
|
39 | })
|
40 | .parse(process.argv);
|
41 |
|
42 | cli(program);
|