Permalink
Browse files

Fix corrupted `options()` call for link and other commands

Summary:
The issue here is that sometimes `this.options()` is not `[options]` but contains different stuff, esp. if your command accepts arguments.

This commit reverts its original behaviour and passes custom `examples` property that we use instead.

Tested, can be shipped right away.

Differential Revision: D3662179

fbshipit-source-id: 4b2af3487464d46e2007388230e675ce3575f797
  • Loading branch information...
1 parent 8419faa commit 504b516947a6cf41bf4067ae2507eb36f8760b85 @grabbou grabbou committed with Facebook Github Bot 5 Aug 3, 2016
Showing with 4 additions and 6 deletions.
  1. +4 −6 local-cli/cliEntry.js
View
@@ -53,7 +53,7 @@ function printHelpInformation() {
let output = [
'',
- chalk.bold(chalk.cyan((` react-native ${cmdName} [options]`))),
+ chalk.bold(chalk.cyan((` react-native ${cmdName} ${this.usage()}`))),
` ${this._description}`,
'',
` ${chalk.bold('Options:')}`,
@@ -62,10 +62,8 @@ function printHelpInformation() {
'',
];
- const usage = this.usage();
-
- if (usage !== '[options]') {
- const formattedUsage = usage.map(
+ if (this.examples && this.examples.length > 0) {
+ const formattedUsage = this.examples.map(
example => ` ${example.desc}: \n ${chalk.cyan(example.cmd)}`,
).join('\n\n');
@@ -100,7 +98,6 @@ const addCommand = (command: Command, config: Config) => {
.command(command.name, undefined, {
noHelp: !command.description,
})
- .usage(command.examples)
.description(command.description)
.action(function runAction() {
const passedOptions = this.opts();
@@ -115,6 +112,7 @@ const addCommand = (command: Command, config: Config) => {
});
cmd.helpInformation = printHelpInformation.bind(cmd);
+ cmd.examples = command.examples;
options
.forEach(opt => cmd.option(

0 comments on commit 504b516

Please sign in to comment.