Skip to content

Commit 80fb300

Browse files
committed
update README.md + useGlobalColumns default = true
1 parent 7c28519 commit 80fb300

4 files changed

Lines changed: 93 additions & 56 deletions

File tree

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# massarg
22

3-
Flexible, powerful, and simple command/argument parser for JS applications.
3+
Massarg is a beautiful, flexible, powerful, and simple-to-use command/argument parser for JS
4+
applications, allowing you to create complex but easy applications that consume command-line
5+
arguments and commands.
46

57
Yes, there are a lot of arg parsers. But hear us out.
68

@@ -11,6 +13,10 @@ Yes, there are a lot of arg parsers. But hear us out.
1113
- Options with flexible parsing
1214
- Required options
1315
- Options with multiple values
16+
<<<<<<< Updated upstream
17+
=======
18+
- Nameless options (TBD)
19+
> > > > > > > Stashed changes
1420
- Automatically generated help text:
1521
- Customizable colors
1622
- Customizable header and footer text
@@ -43,6 +49,38 @@ massarg()
4349
.parse()
4450
```
4551

52+
## Quick Start
53+
54+
Here is an example with some commonly used examples to get you started. Keep reading for a complete
55+
documentation of every option.
56+
57+
```typescript
58+
massarg()
59+
.main((options) => console.log("main command", options))
60+
.command({
61+
name: "sub",
62+
description: "a sub command",
63+
aliases: ["s"],
64+
run: (options) => console.log("sub command", options),
65+
})
66+
.option({
67+
name: "flag",
68+
description: "a flag that will be related to any command (main or sub)",
69+
aliases: ["f"],
70+
boolean: true,
71+
})
72+
.option({
73+
name: "command-specific-flag",
74+
description: "a flag that will be related to only the 'sub' command",
75+
commands: ["sub"],
76+
parse: (v) => parseInt(v),
77+
})
78+
.help({
79+
binName: "my-cli-app",
80+
footer: "Copyright © 2021 Me, Myself and I",
81+
})
82+
```
83+
4684
## Main command
4785

4886
The main command is the one that runs when you supply no other commands.
@@ -172,13 +210,14 @@ you may override their defaults to modify the behavior.
172210
| `printWidth` | `number` | `80` | The amount of characters to allow per line. Use `0` to disable wrapping. |
173211
| `normalColors` | `string \| string[]` | `"dim"` | Colors to use on normal text (descriptions, usage example, etc.) |
174212
| `highlightColors` | `string \| string[]` | `"yellow"` | Colors to use on highlighted text (command names, option names, binary name, etc) |
175-
| `titleColors` | `string \| string[]` | `"white"` | Colors to use on title text ("Options", "Usage", etc) |
213+
| `titleColors` | `string \| string[]` | `["bold", "white"]` | Colors to use on title text ("Options", "Usage", etc) |
176214
| `subtitleColors` | `string \| string[]` | `["bold", "dim"]` | Colors to use on subtitle text (e.g. command titles for non-gloal options) |
215+
| `bodyColors` | `string \| string[]` | `"white"` | Colors to use on special body text (header, footer) |
177216
| `header` | `string` | | Additional content to display below the usage line, and above the rest. |
178217
| `footer` | `string` | | Additional content to display below the commands and options, at the very bottom. |
179218
| `commandNameSeparator` | `string` | `" \| "` | Separator for command name & its aliases. |
180219
| `optionNameSeparator` | `string` | `"\|"` | Separator for option name & its aliases. |
181-
| `useGlobalColumns` | `boolean` | `false` | Decides whether to align the columns of the option/command names and their descriptions globally or per table |
220+
| `useGlobalColumns` | `boolean` | `true` | Decides whether to align the columns of the option/command names and their descriptions globally or per table |
182221
| `usageExample` | `string` | `"[command] [option]"` | Default text to use as suffix for the `binName`, which will be used in the "Usage" line of the help text |
183222
| `useColors` | `boolean` | `true` | When false, no colors will be output in the help. Good for non-supporting systems. |
184223

@@ -198,12 +237,11 @@ massarg().help({
198237
footer: "Footer text",
199238
commandNameSeparator: " | ",
200239
optionNameSeparator: "|",
201-
useGlobalColumns: false,
202-
usageExample: "[command] [option]",
240+
useGlobalColumns: true,
241+
usageExample: "command [option]",
203242
})
204243
```
205244

206245
#### Shell output
207246

208-
![image](https://user-images.githubusercontent.com/167217/126082783-fccd5688-739b-46aa-b50f-3d7609a979b7.png)
209-
247+
![colored shell output](https://user-images.githubusercontent.com/167217/126082881-bb92d4d2-5d2e-4f7b-a2e5-8098bff1a37c.png)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "massarg",
3-
"version": "0.1.0-pre.12",
3+
"version": "0.1.0-pre.13",
44
"description": "Flexible, powerful, and simple command/argument parser for CLI applications",
55
"main": "index.js",
66
"repository": "https://github.com/chenasraf/massarg.git",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class Massarg<Options extends OptionsBase = OptionsBase> {
2929
footer: "",
3030
commandNameSeparator: " | ",
3131
optionNameSeparator: "|",
32-
useGlobalColumns: false,
32+
useGlobalColumns: true,
3333
usageExample: "[command] [options]",
3434
useColors: true,
3535
includeDefaults: true,

src/sample.ts

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,55 @@
11
import massarg from "."
22

33
massarg()
4-
// .help({
5-
// // printWidth: 0,
6-
// binName: "my-cmd",
7-
// useGlobalColumns: true,
8-
// header: "This is the app description",
9-
// footer: "Copyright",
10-
// usageExample: "command [options]",
11-
// useColors: false,
12-
// })
13-
// .option({
14-
// name: "bool",
15-
// aliases: ["b"],
16-
// defaultValue: false,
17-
// commands: ["do", "cc"],
18-
// description: "This is a boolean arg. Supply it without value to set as true, or set value 0 for false",
19-
// required: true,
20-
// parse: Boolean,
21-
// })
22-
// .option({
23-
// name: "number",
24-
// aliases: ["n"],
25-
// description: "This is a number arg, if you include this option, you must supply it with a value.",
26-
// defaultValue: 0,
27-
// commands: "do",
28-
// parse: (v) => parseInt(v),
29-
// })
30-
// .command({
31-
// name: "do-something",
32-
// description: "This command does something. This description is just to fill the blanks. Don't kill the messenger.",
33-
// aliases: ["do", "d"],
34-
// run: console.log.bind(undefined, "do"),
35-
// })
36-
// .command({
37-
// name: "my-custom-command",
38-
// description:
39-
// "This is another command that does something. It's a different one just to see more available. This " +
40-
// "description is just to fill the blanks. Don't kill the messenger.",
41-
// aliases: ["cc", "c"],
42-
// run: console.log.bind(undefined, "do"),
43-
// })
44-
// .main(console.log.bind(undefined, "main"))
45-
.command({
46-
name: "cmd",
47-
description: "Command",
48-
run: () => void 0,
4+
.help({
5+
// printWidth: 0,
6+
binName: "my-cmd",
7+
useGlobalColumns: true,
8+
header: "This is the header",
9+
footer: "This is the footer",
10+
usageExample: "command [options]",
11+
})
12+
.option({
13+
name: "bool",
14+
aliases: ["b"],
15+
defaultValue: false,
16+
commands: ["do", "cc"],
17+
description: "This is a boolean arg. Supply it without value or with 1 to set as true, or set value 0 for false",
18+
required: true,
19+
parse: Boolean,
4920
})
5021
.option({
5122
name: "number",
52-
description: "Number value",
53-
commands: "cmd",
23+
aliases: ["n"],
24+
description: "This is a number arg, if you include this option, you must supply it with a value.",
25+
defaultValue: 0,
26+
commands: "do",
5427
parse: (v) => parseInt(v),
5528
})
29+
.command({
30+
name: "do-something",
31+
description: "This command does something.",
32+
aliases: ["do", "d"],
33+
run: console.log.bind(undefined, "do"),
34+
})
35+
.command({
36+
name: "my-custom-command",
37+
description:
38+
"This is another command that does something. It's a different one just to see more available. This " +
39+
"description is just to fill more lines.",
40+
aliases: ["cc", "c"],
41+
run: console.log.bind(undefined, "do"),
42+
})
43+
.main(console.log.bind(undefined, "main"))
44+
// .command({
45+
// name: "cmd",
46+
// description: "Command",
47+
// run: () => void 0,
48+
// })
49+
// .option({
50+
// name: "number",
51+
// description: "Number value",
52+
// commands: "cmd",
53+
// parse: (v) => parseInt(v),
54+
// })
5655
.parse()

0 commit comments

Comments
 (0)