Skip to content

Commit e27ea93

Browse files
withinboredomdanez
authored andcommitted
Replace nomnom with commanderjs (#142)
* Replace nonom with commander * Update help
1 parent 516fa5e commit e27ea93

File tree

2 files changed

+44
-53
lines changed

2 files changed

+44
-53
lines changed

bin/react-docgen.js

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,46 @@
99
*
1010
*/
1111

12-
var argv = require('nomnom')
13-
.script('react-docgen')
14-
.help(
15-
'Extract meta information from React components.\n' +
16-
'If a directory is passed, it is recursively traversed.'
17-
)
18-
.options({
19-
path: {
20-
position: 0,
21-
help: 'A component file or directory. If no path is provided it reads from stdin.',
22-
metavar: 'PATH',
23-
list: true,
24-
},
25-
out: {
26-
abbr: 'o',
27-
help: 'store extracted information in FILE',
28-
metavar: 'FILE',
29-
},
30-
pretty: {
31-
help: 'pretty print JSON',
32-
flag: true,
33-
},
34-
extension: {
35-
abbr: 'x',
36-
help: 'File extensions to consider. Repeat to define multiple extensions. Default:',
37-
list: true,
38-
default: ['js', 'jsx'],
39-
},
40-
excludePatterns: {
41-
abbr: 'e',
42-
full: 'exclude',
43-
help: 'Filename pattern to exclude. Default:',
44-
list: true,
45-
default: [],
46-
},
47-
ignoreDir: {
48-
abbr: 'i',
49-
full: 'ignore',
50-
help: 'Folders to ignore. Default:',
51-
list: true,
52-
default: ['node_modules', '__tests__', '__mocks__'],
53-
},
54-
resolver: {
55-
help: 'Resolver name (findAllComponentDefinitions, findExportedComponentDefinition) or path to a module that exports a resolver.',
56-
metavar: 'RESOLVER',
57-
default: 'findExportedComponentDefinition',
58-
},
59-
})
60-
.parse();
12+
var argv = require('commander');
13+
14+
function collect(val, memo) {
15+
memo.push(val);
16+
return memo;
17+
}
18+
19+
argv
20+
.usage('[path...] [options]')
21+
.description(
22+
'Extract meta information from React components.\n' +
23+
' If a directory is passed, it is recursively traversed.')
24+
.option(
25+
'-o, --out <file>',
26+
'Store extracted information in the FILE')
27+
.option(
28+
'--pretty',
29+
'pretty print JSON')
30+
.option(
31+
'-x, --extension <extension>',
32+
'File extensions to consider. Repeat to define multiple extensions. Default: js, jsx',
33+
collect,
34+
['js', 'jsx'])
35+
.option(
36+
'-e, --exclude <path>',
37+
'Filename pattern to exclude.',
38+
collect,
39+
[])
40+
.option(
41+
'-i, --ignore <path>',
42+
'Folders to ignore',
43+
collect,
44+
['node_modules', '__tests__', '__mocks__'])
45+
.option(
46+
'--resolver <resolver>',
47+
'Resolver name (findAllComponentDefinitions, findExportedComponentDefinition) or path to a module that exports a resolver.',
48+
'findExportedComponentDefinition')
49+
.arguments('<path>');
50+
51+
argv.parse(process.argv);
6152

6253
var async = require('async');
6354
var dir = require('node-dir');
@@ -66,10 +57,10 @@ var parser = require('../dist/main');
6657
var path = require('path');
6758

6859
var output = argv.out;
69-
var paths = argv.path || [];
60+
var paths = argv.args || [];
7061
var extensions = new RegExp('\\.(?:' + argv.extension.join('|') + ')$');
71-
var ignoreDir = argv.ignoreDir;
72-
var excludePatterns = argv.excludePatterns;
62+
var ignoreDir = argv.ignore;
63+
var excludePatterns = argv.exclude;
7364
var resolver;
7465
var errorMessage;
7566

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"async": "^1.4.2",
3232
"babel-runtime": "^6.9.2",
3333
"babylon": "~5.8.3",
34+
"commander": "^2.9.0",
3435
"doctrine": "^1.2.0",
3536
"node-dir": "^0.1.10",
36-
"nomnom": "^1.8.1",
3737
"recast": "^0.11.5"
3838
},
3939
"devDependencies": {

0 commit comments

Comments
 (0)