packages/cli/src/cliEntry.js
function printHelpInformation(examples, pkg) {
  let cmdName = this._name;
  if (this._alias) {
    cmdName = `${cmdName}|${this._alias}`;
  }

  const sourceInformation = pkg
    ? [`${chalk.bold('Source:')} ${pkg.name}@${pkg.version}`, '']
    : [];

  let output = [
    chalk.bold(`react-native ${cmdName}`),
    this._description ? `\n${this._description}\n` : '',
    ...sourceInformation,
    `${chalk.bold('Options:')}`,
    this.optionHelp().replace(/^/gm, '  '),
  ];

  if (examples && examples.length > 0) {
    const formattedUsage = examples
      .map(example => `  ${example.desc}: \n  ${chalk.cyan(example.cmd)}`)
      .join('\n\n');

    output = output.concat([chalk.bold('\nExample usage:'), formattedUsage]);
  }

  return output.join('\n').concat('\n');
}
function printHelpInformation(examples, pkg) {
  let cmdName = this._name;
  if (this._alias) {
    cmdName = `${cmdName}|${this._alias}`;
  }

  const sourceInformation = pkg
    ? [`${chalk.bold('Source:')} ${pkg.name}@${pkg.version}`, '']
    : [];

  let output = [
    chalk.bold(`react-native ${cmdName}`),
    this._description ? `\n${this._description}\n` : '',
    ...sourceInformation,
    `${chalk.bold('Options:')}`,
    this.optionHelp().replace(/^/gm, '  '),
  ];

  if (examples && examples.length > 0) {
    const formattedUsage = examples
      .map(example => `  ${example.desc}: \n  ${chalk.cyan(example.cmd)}`)
      .join('\n\n');

    output = output.concat([chalk.bold('\nExample usage:'), formattedUsage]);
  }

  return output.join('\n').concat('\n');
}
function printHelpInformation ( examples , pkg ) { let cmdName = this . _name ; if ( this . _alias ) { cmdName = ` ${ cmdName } ${ this . _alias } ` ; } const sourceInformation = pkg ? [ ` ${ chalk . bold ( 'Source:' ) } ${ pkg . name } ${ pkg . version } ` , '' ] : [ ] ; let output = [ chalk . bold ( ` ${ cmdName } ` ) , this . _description ? ` \n ${ this . _description } \n ` : '' , ... sourceInformation , ` ${ chalk . bold ( 'Options:' ) } ` , this . optionHelp ( ) . replace ( / ^ / gm , '  ' ) , ] ; if ( examples && examples . length > 0 ) { const formattedUsage = examples . map ( example => ` ${ example . desc } \n ${ chalk . cyan ( example . cmd ) } ` ) . join ( '\n\n' ) ; output = output . concat ( [ chalk . bold ( '\nExample usage:' ) , formattedUsage ] ) ; } return output . join ( '\n' ) . concat ( '\n' ) ; }
Custom printHelpInformation command inspired by internal Commander.js one modified to suit our needs
Custom printHelpInformation command inspired by internal Commander . js one modified to suit our needs