lib/util/setupCLI.js
function GetCommandList(execName, packageJson, Commands) {
  const header = `\
${packageJson.title || packageJson.name || execName} ${packageJson.version}
Usage:    ${execName} ${col.bold('<command>')} [options]
Commands:`;

  const grouped = _.groupBy(Commands, 'helpGroup');
  const sorted = _.mapValues(grouped, arr => _.sortBy(arr, 'helpPriority'));
  const sortedGroups = _.sortBy(sorted, grp => grp[0].helpPriority);
  const longestCmd = _.max(_.map(Commands, cmd => cmd.name.length));
  const commandListStr = _.map(sortedGroups, (helpGroup) => {
    const groupName = _.first(helpGroup).helpGroup;
    return _.flatten([
      `\n  * ${col.primary(groupName)}`,
      _.map(helpGroup, (cmd) => {
        const cmdName = _.padEnd(cmd.name, longestCmd);
        return `    ${col.bold(cmdName)} ${cmd.desc}`;
      }),
    ]).join('\n');
  }).join('\n');

  return `\
${header}
${commandListStr}

Use ${col.bold(`${execName} <command> -h`)} for command-specific help.`;
}
function GetCommandList(execName, packageJson, Commands) {
  const header = `\
${packageJson.title || packageJson.name || execName} ${packageJson.version}
Usage:    ${execName} ${col.bold('<command>')} [options]
Commands:`;

  const grouped = _.groupBy(Commands, 'helpGroup');
  const sorted = _.mapValues(grouped, arr => _.sortBy(arr, 'helpPriority'));
  const sortedGroups = _.sortBy(sorted, grp => grp[0].helpPriority);
  const longestCmd = _.max(_.map(Commands, cmd => cmd.name.length));
  const commandListStr = _.map(sortedGroups, (helpGroup) => {
    const groupName = _.first(helpGroup).helpGroup;
    return _.flatten([
      `\n  * ${col.primary(groupName)}`,
      _.map(helpGroup, (cmd) => {
        const cmdName = _.padEnd(cmd.name, longestCmd);
        return `    ${col.bold(cmdName)} ${cmd.desc}`;
      }),
    ]).join('\n');
  }).join('\n');

  return `\
${header}
${commandListStr}

Use ${col.bold(`${execName} <command> -h`)} for command-specific help.`;
}
function GetCommandList ( execName , packageJson , Commands ) { const header = ` \
 ${ packageJson . title || packageJson . name || execName } ${ packageJson . version } ${ execName } ${ col . bold ( '<command>' ) } ` ; const grouped = _ . groupBy ( Commands , 'helpGroup' ) ; const sorted = _ . mapValues ( grouped , arr => _ . sortBy ( arr , 'helpPriority' ) ) ; const sortedGroups = _ . sortBy ( sorted , grp => grp [ 0 ] . helpPriority ) ; const longestCmd = _ . max ( _ . map ( Commands , cmd => cmd . name . length ) ) ; const commandListStr = _ . map ( sortedGroups , ( helpGroup ) => { const groupName = _ . first ( helpGroup ) . helpGroup ; return _ . flatten ( [ ` \n ${ col . primary ( groupName ) } ` , _ . map ( helpGroup , ( cmd ) => { const cmdName = _ . padEnd ( cmd . name , longestCmd ) ; return ` ${ col . bold ( cmdName ) } ${ cmd . desc } ` ; } ) , ] ) . join ( '\n' ) ; } ) . join ( '\n' ) ; return ` \
 ${ header } ${ commandListStr } ${ col . bold ( ` ${ execName } ` ) } ` ; }
Get list of available sub-commands for package.
Get list of available sub - commands for package .