1
- import React from "react"
2
- import { Link } from "gatsby"
1
+ import React from "react" ;
2
+ import { Link } from "gatsby" ;
3
3
import {
4
4
MIN_TABLET_MEDIA_QUERY ,
5
5
TABLET_MEDIA_QUERY ,
6
- } from ' typography-breakpoint-constants'
7
- import Layout from "../components/Layout"
8
- import Seo from "../components/Seo"
9
- import Banner from "../components/Banner"
10
- import Section from "../components/Section"
6
+ } from " typography-breakpoint-constants" ;
7
+ import Layout from "../components/Layout" ;
8
+ import Seo from "../components/Seo" ;
9
+ import Banner from "../components/Banner" ;
10
+ import Section from "../components/Section" ;
11
11
12
12
// Syntax
13
- import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'
14
- import js from 'react-syntax-highlighter/dist/esm/languages/prism/javascript'
15
- import bash from 'react-syntax-highlighter/dist/esm/languages/prism/coffeescript'
16
- import tomorrow from 'react-syntax-highlighter/dist/esm/styles/prism/tomorrow'
17
- SyntaxHighlighter . registerLanguage ( 'javascript' , js ) ;
18
- SyntaxHighlighter . registerLanguage ( 'bash' , bash ) ;
19
-
13
+ import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter" ;
14
+ import js from "react-syntax-highlighter/dist/esm/languages/prism/javascript" ;
15
+ import bash from "react-syntax-highlighter/dist/esm/languages/prism/coffeescript" ;
16
+ import tomorrow from "react-syntax-highlighter/dist/esm/styles/prism/tomorrow" ;
17
+ SyntaxHighlighter . registerLanguage ( "javascript" , js ) ;
18
+ SyntaxHighlighter . registerLanguage ( "bash" , bash ) ;
20
19
21
20
const codeString1 = `
22
21
npm install shell
23
- ` . trim ( )
22
+ ` . trim ( ) ;
24
23
25
24
const codeString2 = `
26
25
git clone http://github.com/adaltas/node-shell.git
27
- ` . trim ( )
26
+ ` . trim ( ) ;
28
27
29
28
const feature1 = `
30
- const shell = require("shell")
29
+ const { shell } = require("shell");
31
30
const app = shell({
32
31
name: "myapp",
33
32
description: "My CLI application",
34
33
options: {
35
- " config" : {
34
+ config: {
36
35
shortcut: "c",
37
- description: "Some option"
38
- }
36
+ description: "Some option",
37
+ },
39
38
},
40
39
commands: {
41
- " start" : {
42
- description: "Start something"
43
- }
44
- }
45
- })
46
- ` . trim ( )
40
+ start: {
41
+ description: "Start something",
42
+ },
43
+ },
44
+ });
45
+ ` . trim ( ) ;
47
46
48
47
const feature2 = `
49
48
/* ... */
50
- const args = app.parse()
51
- console.log(args)
49
+ const args = app.parse();
50
+ console.log(args);
52
51
53
52
// Run \`node myapp -c value start\`
54
- { command: [ 'start' ], config: 'value' }
55
- ` . trim ( )
53
+ // { command: [ 'start' ], config: 'value' }
54
+ ` . trim ( ) ;
56
55
57
56
const feature3 = `
58
- const shell = require("shell")
57
+ const shell = require("shell");
59
58
const app = shell({
60
59
/* ... */
61
- commands: { "start":
62
- {
60
+ commands: {
61
+ start: {
63
62
/* ... */
64
- route: ' ./routes/start.js'
65
- }
66
- }
67
- })
68
- app.route()
63
+ route: " ./routes/start.js",
64
+ },
65
+ },
66
+ });
67
+ app.route();
69
68
70
69
/* The project structure:
71
70
|-- /node-modules
@@ -75,10 +74,10 @@ app.route()
75
74
|-- package.json
76
75
|-- package-lock.json
77
76
*/
78
- ` . trim ( )
77
+ ` . trim ( ) ;
79
78
80
79
const feature4 = `
81
- // Run \`node myapp help\`
80
+ // Run \`node myapp help\`
82
81
NAME
83
82
myapp - My CLI application
84
83
@@ -96,78 +95,82 @@ COMMANDS
96
95
EXAMPLES
97
96
myapp --help Show this message
98
97
myapp help Show this message
99
- ` . trim ( )
100
-
98
+ ` . trim ( ) ;
101
99
102
100
const styles = {
103
101
descContainer : {
104
- maxWidth : ' 800px' ,
105
- margin : ' 0 auto' ,
106
- textAlign : ' center' ,
107
- marginBottom : ' 2rem' ,
102
+ maxWidth : " 800px" ,
103
+ margin : " 0 auto" ,
104
+ textAlign : " center" ,
105
+ marginBottom : " 2rem" ,
108
106
} ,
109
107
section : {
110
- ' & h2' : {
108
+ " & h2" : {
111
109
textAlign : "center" ,
112
110
} ,
113
- ' > div > div' : {
114
- display : ' flex' ,
115
- justifyContent : ' space-between' ,
116
- marginBottom : ' 2rem' ,
117
- ' & p' : {
118
- margin : ' 1.2rem 0' ,
119
- ' &:last-child' : {
120
- textAlign : ' center' ,
121
- }
111
+ " > div > div" : {
112
+ display : " flex" ,
113
+ justifyContent : " space-between" ,
114
+ marginBottom : " 2rem" ,
115
+ " & p" : {
116
+ margin : " 1.2rem 0" ,
117
+ " &:last-child" : {
118
+ textAlign : " center" ,
119
+ } ,
122
120
} ,
123
121
[ TABLET_MEDIA_QUERY ] : {
124
- flexDirection : ' column' ,
125
- marginBottom : ' 3rem' ,
126
- ' & h3' : {
127
- textAlign : ' center' ,
122
+ flexDirection : " column" ,
123
+ marginBottom : " 3rem" ,
124
+ " & h3" : {
125
+ textAlign : " center" ,
128
126
} ,
129
127
} ,
130
128
[ MIN_TABLET_MEDIA_QUERY ] : {
131
- 'h3' : {
132
- marginTop : ' .5rem' ,
129
+ h3 : {
130
+ marginTop : " .5rem" ,
133
131
} ,
134
- ' &:nth-of-type(odd)' : {
135
- ' & > div:nth-of-type(odd)' : {
132
+ " &:nth-of-type(odd)" : {
133
+ " & > div:nth-of-type(odd)" : {
136
134
width : "43%" ,
137
135
order : 2 ,
138
136
} ,
139
- ' & > div:nth-of-type(even)' : {
137
+ " & > div:nth-of-type(even)" : {
140
138
width : "53%" ,
141
139
order : 1 ,
142
140
} ,
143
141
} ,
144
- }
142
+ } ,
145
143
} ,
146
144
} ,
147
145
button : {
148
- border : ' 1px solid #fff' ,
149
- color : ' #fff' ,
150
- padding : ' 10px 30px' ,
151
- borderRadius : ' 3px' ,
152
- textDecoration : ' none' ,
153
- ' &:hover' : {
154
- background : ' rgba(255,255,255,.05)' ,
155
- }
156
- }
157
- }
146
+ border : " 1px solid #fff" ,
147
+ color : " #fff" ,
148
+ padding : " 10px 30px" ,
149
+ borderRadius : " 3px" ,
150
+ textDecoration : " none" ,
151
+ " &:hover" : {
152
+ background : " rgba(255,255,255,.05)" ,
153
+ } ,
154
+ } ,
155
+ } ;
158
156
159
157
const IndexPage = ( ) => (
160
158
< Layout isHome = { true } >
161
159
< Seo
162
160
title = "Shell.js - argument parsing for Node.js CLI applications"
163
161
keywords = { [
164
- 'shell' , 'cli' , 'arguments' , 'parameters' ,
165
- 'router' , 'parse' , 'stringify' ,
162
+ "shell" ,
163
+ "cli" ,
164
+ "arguments" ,
165
+ "parameters" ,
166
+ "router" ,
167
+ "parse" ,
168
+ "stringify" ,
166
169
] }
167
170
/>
168
171
< Banner />
169
172
< div css = { styles . homePage } >
170
- < Section classes = { { root : styles . section } } >
173
+ < Section classes = { { root : styles . section } } >
171
174
< h2 > Why Shell.js?</ h2 >
172
175
< div >
173
176
< div >
@@ -180,7 +183,7 @@ const IndexPage = () => (
180
183
commands and to generate help screens.
181
184
</ p >
182
185
< p >
183
- < Link to = ' /config/' css = { styles . button } >
186
+ < Link to = " /config/" css = { styles . button } >
184
187
Read more
185
188
</ Link >
186
189
</ p >
@@ -196,9 +199,12 @@ const IndexPage = () => (
196
199
< div >
197
200
< h3 > Parse arguments</ h3 >
198
201
< div >
199
- < p > For the handling and adding the functionality to the application operate with the `args` object returned with the method `parse`.</ p >
200
202
< p >
201
- < Link to = '/api/parse/' css = { styles . button } >
203
+ For the handling and adding the functionality to the application
204
+ operate with the `args` object returned with the method `parse`.
205
+ </ p >
206
+ < p >
207
+ < Link to = "/api/parse/" css = { styles . button } >
202
208
Read more
203
209
</ Link >
204
210
</ p >
@@ -214,9 +220,11 @@ const IndexPage = () => (
214
220
< div >
215
221
< h3 > Organize the code with routing</ h3 >
216
222
< div >
217
- < p > Load and configure the router in a separate top-level module.</ p >
218
223
< p >
219
- < Link to = '/usage/routing/' css = { styles . button } >
224
+ Load and configure the router in a separate top-level module.
225
+ </ p >
226
+ < p >
227
+ < Link to = "/usage/routing/" css = { styles . button } >
220
228
Read more
221
229
</ Link >
222
230
</ p >
@@ -232,9 +240,13 @@ const IndexPage = () => (
232
240
< div >
233
241
< h3 > Auto generate help</ h3 >
234
242
< div >
235
- < p > Shell.js convert the configuration object into a readable documentation string about how to use the CLI application or one of its commands.</ p >
236
243
< p >
237
- < Link to = '/api/help/' css = { styles . button } >
244
+ Shell.js convert the configuration object into a readable
245
+ documentation string about how to use the CLI application or one
246
+ of its commands.
247
+ </ p >
248
+ < p >
249
+ < Link to = "/api/help/" css = { styles . button } >
238
250
Read more
239
251
</ Link >
240
252
</ p >
@@ -269,6 +281,6 @@ const IndexPage = () => (
269
281
</ Section >
270
282
</ div >
271
283
</ Layout >
272
- )
284
+ ) ;
273
285
274
- export default IndexPage
286
+ export default IndexPage ;
0 commit comments