-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.html
116 lines (89 loc) · 2.95 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
layout: default
---
<div class="landing-wrapper">
<div class="wrapper">
<div class="title">
<h1 class="pink-highlight">Yargs be a node.js library fer hearties tryin' ter parse optstrings.</h1>
</div>
</div>
</div>
<div class="wrapper">
<div class="page-content align-items">
<div class="page-box-full markdown-body">
<div class="page-heading">What's Yargs?</div>
<p class="description">
Yargs helps you build interactive command line tools by parsing arguments and generating an elegant user interface.
</p>
<p class="description">
Yargs gives you:
</p>
<ul class="description">
<li> commands and (grouped) options (like module run -n --force),</li>
<li> a dynamically generated help menu based on your arguments, </li>
<li> bash-completion shortcuts for commands and options, </li>
<li> and much more. </li>
</ul>
<p class="description">
With these features, and many more, yargs allows you to focus on building your program without worrying about your args.
</p>
</div>
<div class="page-box">
<div class="page-heading">Install</div>
<p class="description">
Open your terminal, navigate to your project, and run using npm:
</p>
<div class="sh-code">
$ npm install --save yargs
</div>
</div>
</div>
<div class="page-content align-items">
<div class="page-box">
<div class="page-heading"> Getting Started </div>
<div class="instructions"> After creating example.js start with the following code to get you going: </div>
<pre>
<code class="hljs language-javascript">
#!/usr/bin/env node
require('yargs')
.scriptName("pirate-parser")
.usage('$0 <cmd> [args]')
.command('hello [name]', 'welcome ter yargs!', (yargs) => {
yargs.positional('name', {
type: 'string',
default: 'Cambi',
describe: 'the name to say hello to'
})
}, function (argv) {
console.log('hello', argv.name, 'welcome to yargs!')
})
.help()
.argv
</code>
</pre>
<div class="instructions"> And in your terminal run: </div>
<pre>
<code class="hljs language-bash">
$ node example.js --help
</code>
</pre>
<div class="instructions"> To get this output: </div>
<pre>
<code class="hljs language-bash">
pirate-parser <cmd> [args]
Commands:
pirate-parser hello [name] welcome ter yargs!
Options:
--help Show help [boolean]
</code>
</pre>
<div class="instructions"> Run hello command: </div>
<pre>
<code class="hljs language-bash">
$ node example.js hello --name Parrot
hello Parrot welcome to yargs!
</code>
</pre>
</div>
</div>
</div>