Last active
August 29, 2015 14:23
-
-
Save gullitmiranda/54e5c04cd4ff5bc02018 to your computer and use it in GitHub Desktop.
How we did it `azk` CLI.
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
#!/usr/bin/env node | |
var Cli = require('cli-router').Cli; | |
var cli = new Cli({ | |
// Caminho para o arquivo de usage (seguindo o padrão do docopt. | |
path: path.join(__dirname, `usage.txt`), | |
// Diretório onde estão os controladores | |
controllers_root: path.join(__dirname, "controllers") | |
}); | |
cli | |
.route('help', function(p, args) { return p.help || p['--help'] || args.length <= 0 }) | |
.route('version', function(p) { return p.version || p['--version'] }) | |
.route('hello'); | |
// passa os argumentos para o cli-router executar | |
var result = cli.run({ argv: process.argv.slice(2) }); | |
console.log(result); |
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
Hello Word | |
Usage: | |
usage hello <name> [--help] | |
usage version | |
usage [--version | -h | --help] | |
Options: | |
--help, -h Show this help. | |
--version Show version. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment