const print = require('../../helpers/print');
const docs = global.ESBUILD ? require('../index?nocache') : require('../index');

const readme = require('./readme.md');

/**
 * @param {{}} flags
 * @param {string[]} attributes
 * @returns {*}
 */
function help(flags = {}, [originalCommand] = []) {
  let command = originalCommand;

  if (typeof docs[command] === 'undefined') {
    command = 'help';
  }

  const docsContent = docs[command]?.readme || readme;

  return print(docsContent);
}

module.exports = help;
