forked from yargs/yargs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add .commandDir(dir) to API to apply all command modules from a…
… relative directory (yargs#494) * feat: add .commandDir() API using require-directory * support for nested subcommands with relative dir * allow command module to only define command and desc * test: add some for commandDir * docs: document the .commandDir() method * use const where possible based on @maxrimue's review
- Loading branch information
Showing
11 changed files
with
426 additions
and
6 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
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,28 @@ | ||
exports.command = 'limbo [opts]' | ||
exports.desc = 'Get lost in pure subconscious' | ||
exports.builder = { | ||
'with-self-exit': { | ||
desc: 'Pretty much your only way out', | ||
type: 'boolean' | ||
}, | ||
'with-totem': { | ||
desc: 'Take your totem with you', | ||
type: 'boolean' | ||
} | ||
} | ||
exports.handler = function (argv) { | ||
var factor = 3 | ||
if (!argv.withSelfExit) throw new Error('You entered limbo without a way out!') | ||
if (!argv.withTotem) factor -= 2 | ||
if (argv.extract) { | ||
if (!chancesLevel4(factor)) throw new Error('You didn\'t have much chance anyway, you\'re stuck in limbo!') | ||
if (!argv._msg) argv._msg = 'You have accomplished the impossible. Inception successful.' | ||
return | ||
} | ||
if (!chancesLevel4(factor)) throw new Error('You rolled the dice and lost, you\'re stuck in limbo!') | ||
if (!argv._msg) argv._msg = 'Can you ever be sure of what\'s real anymore?' | ||
} | ||
|
||
function chancesLevel4 (factor) { | ||
return Math.floor(Math.random() * 10) < factor | ||
} |
Oops, something went wrong.