diff --git a/bin/cli b/bin/cli index 774129a..06c8edb 100755 --- a/bin/cli +++ b/bin/cli @@ -12,15 +12,25 @@ updateNotifier({ pkg }).notify(); cli.version(pkg.version); -const addCommand = (command) => - cli +const defaultOptParser = (val) => val; + +const addCommand = (command) => { + const cmd = cli .command(command.name) .usage(command.usage) .description(command.description) .action(function runAction() { - command.func(config, arguments); + command.func(config, arguments, this.opts()); }); + (command.options || []) + .forEach(opt => cmd.option( + opt.flags, + opt.description, + opt.parse || defaultOptParser, + opt.default + )); +}; flatten(commands).forEach(addCommand); diff --git a/package.json b/package.json index 1d3df49..737af64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rnpm", - "version": "1.7.0", + "version": "1.8.0", "description": "React Native Package Manager", "main": "./src/getCommands.js", "scripts": {