azukiapp/azk

View on GitHub
src/cmds/help.js

Summary

Maintainability
A
0 mins
Test Coverage
import { CliControllers } from 'cli-router';
import { _, t } from 'azk';
import { promiseResolve } from 'azk/utils/promises';

export default class Help extends CliControllers.Help {
  index(params, cli) {
    var usage = super.index(params, cli);
    usage = this.colorizeSections(params, usage);
    this.ui.output(usage);
    return promiseResolve(0);
  }

  colorizeSections(params, usage) {
    _.map(this.sections, (section) => {
      var regex = new RegExp(`^${section}:`, 'gmi');
      usage = usage.replace(regex, t(`commands.help.${section}`));
    });
    return usage;
  }
}