1 | 'use strict'
|
2 | const commandLineArgs = require('../')
|
3 | const commandLineUsage = require('command-line-usage')
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const optionDefinitions = [
|
11 | {
|
12 | name: 'help',
|
13 | alias: 'h',
|
14 | type: Boolean,
|
15 | description: 'Display this usage guide.'
|
16 | },
|
17 | {
|
18 | name: 'src',
|
19 | type: String,
|
20 | multiple: true,
|
21 | defaultOption: true,
|
22 | description: 'The input files to process',
|
23 | typeLabel: '<files>' },
|
24 | {
|
25 | name: 'timeout',
|
26 | alias: 't',
|
27 | type: Number,
|
28 | description: 'Timeout value in ms',
|
29 | typeLabel: '<ms>' },
|
30 | {
|
31 | name: 'log',
|
32 | alias: 'l',
|
33 | type: Boolean,
|
34 | description: 'info, warn or error'
|
35 | }
|
36 | ]
|
37 |
|
38 | const options = commandLineArgs(optionDefinitions)
|
39 |
|
40 | if (options.help) {
|
41 | const usage = commandLineUsage([
|
42 | {
|
43 | header: 'Typical Example',
|
44 | content: 'A simple example demonstrating typical usage.'
|
45 | },
|
46 | {
|
47 | header: 'Options',
|
48 | optionList: optionDefinitions
|
49 | },
|
50 | {
|
51 | content: 'Project home: [underline]{https://github.com/me/example}'
|
52 | }
|
53 | ])
|
54 | console.log(usage)
|
55 | }
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|