You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The data to be converted into an array of arguments.
15
-
*`options` (object)
16
+
-`options` (object)
16
17
Options used to alter the behavior of the `compile` method.
17
-
*`extended` (boolean, optional, `false`)
18
-
The value `true` indicates that the parameters are provided in extended format, default to the configuration `extended` value which is `false` by default.
19
-
*`script` (string, optional, `false`)
20
-
The JavaScript file being executed by the Node.js engine. When provided, the Node.js engine and the script names will prepend the returned arguments.
21
-
* Returns: (array)
18
+
-`extended` (boolean, optional, `false`)
19
+
The value `true` indicates that the parameters are provided in extended format, default to the configuration `extended` value which is `false` by default.
20
+
-`script` (string, optional, `false`)
21
+
The JavaScript file being executed by the Node.js engine. When provided, the Node.js engine and the script names will prepend the returned arguments.
22
+
- Returns: (array)
22
23
The command line arguments.
23
24
24
25
## Description
@@ -32,69 +33,97 @@ It supports both the default flatten mode and the extended mode. The `extended`
32
33
Considering a "server" application containing a "start" command and initialised with the following configuration:
33
34
34
35
```js
35
-
require("should")
36
-
constshell=require("shell")
37
-
constapp=shell(
38
-
{ name:"server",
36
+
require("should");
37
+
const{ shell} =require("shell");
38
+
constapp=shell({
39
+
name:"server",
39
40
description:"Manage a web server",
40
-
options:
41
-
{ "config":
42
-
{ shortcut:"c" } },
43
-
commands:
44
-
{ "start":
45
-
{ description:"Start a web server",
46
-
options:
47
-
{ "host":
48
-
{ shortcut:"h",
49
-
description:"Web server listen host"},
50
-
"port":
51
-
{ shortcut:"p", type:"integer",
52
-
description:"Web server listen port" } } } } })
41
+
options: { config: { shortcut:"c" } },
42
+
commands: {
43
+
start: {
44
+
description:"Start a web server",
45
+
options: {
46
+
host: { shortcut:"h", description:"Web server listen host" },
47
+
port: {
48
+
shortcut:"p",
49
+
type:"integer",
50
+
description:"Web server listen port",
51
+
},
52
+
},
53
+
},
54
+
},
55
+
});
53
56
```
54
57
55
58
Called with only the `config` option, the `compile` method convert an object literal into a shell command:
56
59
57
-
```javascript
58
-
app.compile({
59
-
config:"app.yaml"
60
-
})
61
-
.should.eql( [ "--config", "app.yaml" ] )
60
+
```js
61
+
app
62
+
.compile({
63
+
config:"app.yaml",
64
+
})
65
+
.should.eql(["--config", "app.yaml"]);
62
66
```
63
67
64
68
In extended mode, the data input will be an array instead of an object:
Determine if help was requested by returning zero to n commands if help is requested or null otherwise.
12
12
13
-
*`params` ([object] | object)
13
+
-`params` ([object] | object)
14
14
The parameter object parsed from arguments, an object in flatten mode or an array in extended mode, optional.
15
15
16
16
## Description
@@ -22,25 +22,30 @@ This method is commonly used conjointly with the `help` method. It provides an i
22
22
The workflow is to `parse` the arguments to get the extracted data, to create a condition to get the command associated with help and to print the help by passing the returned command:
23
23
24
24
```js
25
-
constshell=require('shell')
25
+
const{ shell} =require("shell");
26
26
constapp=shell({
27
-
name:'server',
28
-
description:'Manage a web server',
27
+
name:"server",
28
+
description:"Manage a web server",
29
29
commands: {
30
-
'start': {
31
-
description:'Start a web server',
30
+
start: {
31
+
description:"Start a web server",
32
32
options: {
33
-
'host': {shortcut:'h', description:'Web server listen host'},
34
-
'port': {shortcut:'p', type:'integer', description:'Web server listen port'}
35
-
}
36
-
}
37
-
}
33
+
host: { shortcut:"h", description:"Web server listen host" },
0 commit comments