Skip to content

Commit

Permalink
feat: show help when no arguments are provided (#160)
Browse files Browse the repository at this point in the history
* feat: show help when no arguments are provided

* fix: add unknown command info back

* chore: visual adjustments
  • Loading branch information
lucasbento authored and Esemesek committed Feb 11, 2019
1 parent 72c3dd4 commit fb62f9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
18 changes: 9 additions & 9 deletions packages/cli/src/cliEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ function printHelpInformation() {
}

function printUnknownCommand(cmdName) {
logger.error(
[
cmdName
? `Unrecognized command "${cmdName}".`
: "You didn't pass any command.",
`Run ${chalk.white(
if (cmdName) {
logger.error(`Unrecognized command "${chalk.bold(cmdName)}".`);
logger.info(
`Run ${chalk.bold(
'"react-native --help"'
)} to see list of all available commands.`,
].join(' ')
);
)} to see a list of all available commands.`
);
} else {
commander.outputHelp();
}
}

const addCommand = (command: CommandT, ctx: ContextT) => {
Expand Down
9 changes: 1 addition & 8 deletions packages/global-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const commands = options._;
if (cli) {
cli.run();
} else {
if (options._.length === 0 && (options.h || options.help)) {
if (options._.length === 0 && (options.h || options.help) || commands.length === 0) {
console.log(
[
'',
Expand All @@ -136,13 +136,6 @@ if (cli) {
process.exit(0);
}

if (commands.length === 0) {
console.error(
'You did not pass any commands, run `react-native --help` to see a list of all available commands.'
);
process.exit(1);
}

switch (commands[0]) {
case 'init':
if (!commands[1]) {
Expand Down

0 comments on commit fb62f9b

Please sign in to comment.