1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const optionator = require('optionator');
|
12 | const pkg = require('../package.json');
|
13 | const reactDOMSupport = require('./reactDOMSupport');
|
14 | const reactNativeSupport = require('./reactNativeSupport');
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | module.exports = optionator({
|
22 | prepend:
|
23 | `${pkg.name} v${pkg.version}
|
24 | ${pkg.description}
|
25 |
|
26 | Usage:
|
27 | $ rt <filename> [<filename> ...] [<args>]`,
|
28 | concatRepeatedArrays: true,
|
29 | mergeRepeatedObjects: true,
|
30 | options: [{
|
31 | heading: 'Options'
|
32 | }, {
|
33 | option: 'help',
|
34 | alias: 'h',
|
35 | type: 'Boolean',
|
36 | description: 'Show help.'
|
37 | }, {
|
38 | option: 'color',
|
39 | alias: 'c',
|
40 | default: 'true',
|
41 | type: 'Boolean',
|
42 | description: 'Use colors in output.'
|
43 | }, {
|
44 | option: 'modules',
|
45 | alias: 'm',
|
46 | default: 'none',
|
47 | type: 'String',
|
48 | description: 'Use output modules. (amd|commonjs|none|es6|typescript|jsrt)'
|
49 | }, {
|
50 | option: 'name',
|
51 | alias: 'n',
|
52 | type: 'String',
|
53 | description: 'When using globals, the name for the variable. The default is the [file name]RT, when using amd, the name of the module'
|
54 | }, {
|
55 | option: 'dry-run',
|
56 | alias: 'd',
|
57 | default: 'false',
|
58 | type: 'Boolean',
|
59 | description: 'Run compilation without creating an output file, used to check if the file is valid'
|
60 | }, {
|
61 | option: 'force',
|
62 | alias: 'r',
|
63 | default: 'false',
|
64 | type: 'Boolean',
|
65 | description: 'Force creation of output. skip file check.'
|
66 | }, {
|
67 | option: 'format',
|
68 | alias: 'f',
|
69 | type: 'String',
|
70 | default: 'stylish',
|
71 |
|
72 | description: 'Use a specific output format. (stylish|json)'
|
73 | }, {
|
74 | option: 'target-version',
|
75 | alias: 't',
|
76 | type: 'String',
|
77 | default: reactDOMSupport.default,
|
78 | description: `'React version to generate code for (${Object.keys(reactDOMSupport).join(', ')})'`
|
79 | }, {
|
80 | option: 'list-target-version',
|
81 | type: 'Boolean',
|
82 | default: 'false',
|
83 | description: 'Show list of target versions'
|
84 | }, {
|
85 | option: 'version',
|
86 | alias: 'v',
|
87 | type: 'Boolean',
|
88 | description: 'Outputs the version number.'
|
89 | }, {
|
90 | option: 'stack',
|
91 | alias: 'k',
|
92 | type: 'Boolean',
|
93 | description: 'Show stack trace on errors.'
|
94 | }, {
|
95 | option: 'react-import-path',
|
96 | default: 'react/addons',
|
97 | type: 'String',
|
98 | description: 'Dependency path for importing React.'
|
99 | }, {
|
100 | option: 'lodash-import-path',
|
101 | default: 'lodash',
|
102 | type: 'String',
|
103 | description: 'Dependency path for importing lodash.'
|
104 | }, {
|
105 | option: 'native',
|
106 | alias: 'rn',
|
107 | type: 'Boolean',
|
108 | description: 'Renders react native templates.'
|
109 | }, {
|
110 | option: 'flow',
|
111 | type: 'Boolean',
|
112 | description: 'Add /* @flow */ to the top of the generated file'
|
113 | }, {
|
114 | option: 'native-target-version',
|
115 | alias: 'rnv',
|
116 | type: 'String',
|
117 | default: reactNativeSupport.default,
|
118 | description: `'React native version to generate code for (${Object.keys(reactNativeSupport).join(', ')})'`
|
119 | }]
|
120 | });
|