-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed color-less alignment, more tests, fixed empty lines
- Loading branch information
Showing
6 changed files
with
155 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,56 @@ | ||
import massarg from "." | ||
|
||
massarg() | ||
.help({ | ||
// printWidth: 0, | ||
binName: "my-cmd", | ||
useGlobalColumns: true, | ||
header: "This is the app description", | ||
footer: "Copyright", | ||
usageExample: "command [options]", | ||
}) | ||
.option({ | ||
name: "bool", | ||
aliases: ["b"], | ||
defaultValue: false, | ||
commands: ["do", "cc"], | ||
description: "This is a boolean arg. Supply it without value to set as true, or set value 0 for false", | ||
required: true, | ||
parse: Boolean, | ||
// .help({ | ||
// // printWidth: 0, | ||
// binName: "my-cmd", | ||
// useGlobalColumns: true, | ||
// header: "This is the app description", | ||
// footer: "Copyright", | ||
// usageExample: "command [options]", | ||
// useColors: false, | ||
// }) | ||
// .option({ | ||
// name: "bool", | ||
// aliases: ["b"], | ||
// defaultValue: false, | ||
// commands: ["do", "cc"], | ||
// description: "This is a boolean arg. Supply it without value to set as true, or set value 0 for false", | ||
// required: true, | ||
// parse: Boolean, | ||
// }) | ||
// .option({ | ||
// name: "number", | ||
// aliases: ["n"], | ||
// description: "This is a number arg, if you include this option, you must supply it with a value.", | ||
// defaultValue: 0, | ||
// commands: "do", | ||
// parse: (v) => parseInt(v), | ||
// }) | ||
// .command({ | ||
// name: "do-something", | ||
// description: "This command does something. This description is just to fill the blanks. Don't kill the messenger.", | ||
// aliases: ["do", "d"], | ||
// run: console.log.bind(undefined, "do"), | ||
// }) | ||
// .command({ | ||
// name: "my-custom-command", | ||
// description: | ||
// "This is another command that does something. It's a different one just to see more available. This " + | ||
// "description is just to fill the blanks. Don't kill the messenger.", | ||
// aliases: ["cc", "c"], | ||
// run: console.log.bind(undefined, "do"), | ||
// }) | ||
// .main(console.log.bind(undefined, "main")) | ||
.command({ | ||
name: "cmd", | ||
description: "Command", | ||
run: () => void 0, | ||
}) | ||
.option({ | ||
name: "number", | ||
aliases: ["n"], | ||
description: "This is a number arg, if you include this option, you must supply it with a value.", | ||
defaultValue: 0, | ||
commands: "do", | ||
description: "Number value", | ||
commands: "cmd", | ||
parse: (v) => parseInt(v), | ||
}) | ||
.command({ | ||
name: "do-something", | ||
description: "This command does something. This description is just to fill the blanks. Don't kill the messenger.", | ||
aliases: ["do", "d"], | ||
run: console.log.bind(undefined, "do"), | ||
}) | ||
.command({ | ||
name: "my-custom-command", | ||
description: | ||
"This is another command that does something. It's a different one just to see more available. This " + | ||
"description is just to fill the blanks. Don't kill the messenger.", | ||
aliases: ["cc", "c"], | ||
run: console.log.bind(undefined, "do"), | ||
}) | ||
.main(console.log.bind(undefined, "main")) | ||
.parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import massarg from "../src" | ||
|
||
describe("print help", () => { | ||
test("should print help without command options", () => { | ||
const helpStr = massarg() | ||
.help({ useColors: false }) | ||
.option({ | ||
name: "number", | ||
description: "Number value", | ||
parse: (v) => parseInt(v), | ||
}) | ||
.getHelpString() | ||
.join("\n") | ||
|
||
expect(helpStr).toBe( | ||
"Usage: processChild.js [command] [options]" + | ||
"\n\n" + | ||
"Options:" + | ||
"\n\n" + | ||
" --help|-h Display help information" + | ||
"\n\n" + | ||
" --number Number value" + | ||
"\n" | ||
) | ||
}) | ||
test("should print help correctly with only global options", () => { | ||
const helpStr = massarg() | ||
.help({ useColors: false }) | ||
.command({ | ||
name: "cmd", | ||
description: "Command", | ||
run: () => void 0, | ||
}) | ||
.option({ | ||
name: "number", | ||
description: "Number value", | ||
parse: (v) => parseInt(v), | ||
}) | ||
.getHelpString() | ||
.join("\n") | ||
|
||
expect(helpStr).toBe( | ||
"Usage: processChild.js [command] [options]" + | ||
"\n\n" + | ||
"Commands:" + | ||
"\n\n" + | ||
" cmd Command" + | ||
"\n\n" + | ||
"Options:" + | ||
"\n\n" + | ||
" --help|-h Display help information" + | ||
"\n\n" + | ||
" --number Number value" + | ||
"\n" | ||
) | ||
}) | ||
|
||
test("should print help correctly with command options", () => { | ||
const helpStr = massarg() | ||
.help({ useColors: false }) | ||
.command({ | ||
name: "cmd", | ||
description: "Command", | ||
run: () => void 0, | ||
}) | ||
.option({ | ||
name: "number", | ||
description: "Number value", | ||
commands: "cmd", | ||
parse: (v) => parseInt(v), | ||
}) | ||
.getHelpString() | ||
.join("\n") | ||
|
||
expect(helpStr).toBe( | ||
"Usage: processChild.js [command] [options]" + | ||
"\n\n" + | ||
"Commands:" + | ||
"\n\n" + | ||
" cmd Command" + | ||
"\n\n" + | ||
"Command Options:" + | ||
"\n\n" + | ||
"cmd:" + | ||
"\n\n" + | ||
" --number Number value" + | ||
"\n\n" + | ||
"Global Options:" + | ||
"\n\n" + | ||
" --help|-h Display help information" + | ||
"\n" | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters