-
Notifications
You must be signed in to change notification settings - Fork 36
/
examples.js
67 lines (65 loc) · 1.69 KB
/
examples.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import commandLineUsage from 'command-line-usage'
const optionDefinitions = [
{
name: 'help',
description: 'Display this usage guide.',
alias: 'h',
type: Boolean
},
{
name: 'src',
description: 'The input files to process. This is some additional text existing solely to demonstrate word-wrapping, nothing more, nothing less. And nothing in between.',
type: String,
multiple: true,
defaultOption: true,
typeLabel: '{underline file} ...'
},
{
name: 'timeout',
description: 'Timeout value in ms.',
alias: 't',
type: Number,
typeLabel: '{underline ms}'
}
]
const sections = [
{
header: 'A typical app',
content: 'Generates something {italic very} important.'
},
{
header: 'Synopsis',
content: [
'$ example [{bold --timeout} {underline ms}] {bold --src} {underline file} ...',
'$ example {bold --help}'
]
},
{
header: 'Options',
optionList: optionDefinitions
},
{
header: 'Examples',
content: 'A list of examples which demonstrate how to use the app.'
},
{
content: [
{
desc: '1. A concise example. ',
example: '$ example -t 100 lib/*.js'
},
{
desc: '2. A long example. ',
example: '$ example --timeout 100 --src lib/*.js'
},
{
desc: '3. This even longer example will scan space for unknown things. Take care when scanning space, it could take some time. ',
example: '$ example --src galaxy1.facts galaxy1.facts galaxy2.facts galaxy3.facts galaxy4.facts galaxy5.facts'
}
]
},
{
content: 'Project home: {underline https://github.com/me/example}'
}
]
console.log(commandLineUsage(sections))