Skip to content

Instantly share code, notes, and snippets.

@lcaballero
Created April 18, 2015 20:49
Show Gist options
  • Save lcaballero/b799e2c3a758a59fed2c to your computer and use it in GitHub Desktop.
Save lcaballero/b799e2c3a758a59fed2c to your computer and use it in GitHub Desktop.
Example generating bash completions.
yargs = require 'yargs'
args = yargs
.options(
t:
alias: "tstuff"
description: "Does t stuff"
b:
alias: "batman"
description: "Bat-option"
h:
alias: "help"
description: "Show help"
s:
alias: "completions-script"
description: "Show completions script."
)
.command(
"generate",
(curr, argv) -> ["foo", "bar"]
)
.argv
if args.help
console.log(yargs.help())
process.exit(1)
if args["completions-script"]
yargs.showCompletionScript()
process.exit(1)
console.log(args._)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment