示例#1
0
// Verify name of a champ. If champ is not found, do a closest string match to find it.
// If no champ can be matched, return the string anyway incase it's a new champ that hasn't been added yet.
function _verifyName(champ) {
  const champ_reg = champ.toLowerCase().replace(/[^a-z]/g, '');
  if (!lol_champs[champ_reg]) {
    const champ_search = didyoumean(champ_reg, R.keys(lol_champs));
    if (champ_search) return champ_search;
  }
  return champ_reg;
}
示例#2
0
 .on('*', function(name) {
     var msgs = ['\n  "' + name + '" is not a known command.'];
     var d = didYouMean(name.toString(), program.commands, "_name");
     if (d) {
         msgs.push('Did you mean: '+ d + ' ?');
     }
     msgs.push('\n\n  See "' + opts.name + ' --help".\n');
     console.error(msgs.join(' '));
     process.exit(1);
 });
 .map((idx, elem) => {
   const name = $c(elem).attr('name');
   const id = $c(elem).attr('id');
   if (!id) return;
   return {
     id,
     name,
     formatted_name: didyoumean(name, store.get('champs')) || name
   };
 })
示例#4
0
    program.on('*', (name) => {
        logger.error(`${chalk.yellow(name)} is not a known command. See '${chalk.white(`${cliName} --help`)}'.`);

        const d = didYouMean(name.toString(), program.commands, '_name');

        if (d) {
            logger.info(`Did you mean: ${chalk.yellow(d)}?`);
        }

        process.exit(1);
    });
示例#5
0
    .on('*', function (name) {
      program.log.error('\'' + name + '\' is not a known command. See \'' + opts.name + ' --help\'.');

      var d = didYouMean(name.toString(), program.commands, '_name');

      if (d) {
        program.log.info('Did you mean:', d, '?');
      }

      process.exit(1);
    });
示例#6
0
文件: UserConfig.js 项目: wuomzfx/umi
 Object.keys(config).forEach(key => {
   if (!pluginNames.includes(key)) {
     if (opts.setConfig) {
       opts.setConfig(config);
     }
     const affixmsg = `选择 "${pluginNames.join(', ')}" 中的一项`;
     const guess = didyoumean(key, pluginNames);
     const midMsg = guess ? `你是不是想配置 "${guess}" ? 或者` : '请';
     const msg = `"${relativeFile}" 中配置的 "${key}" 并非约定的配置项,${midMsg}${affixmsg}`;
     printError(msg);
     throw new Error(msg);
   }
 });
示例#7
0
.fail(function(msg, err){
  if (/Unknown argument/.test(msg)){
    let list = ['install', 'save'];
    let command = msg.split(": ")[1].split(", ")[0];
    let possible = didyoumean(command, list);
    if (possible) {
      yargs.showHelp();
      console.log(error(`Did you mean 'broiler ${possible}'?`));
    } else {
      yargs.showHelp();
      console.log(error(`'${command}' is not a command that broiler understands`));
    }
  }
  process.exit(1)
})
示例#8
0
function validateOptions(options) {
  for (var key in options) {
    var defaultKeys = Object.keys(constants.DEFAULTS);
    if (defaultKeys.indexOf(key) < 0) {
      var match;
      var msg = "Unknown option '" + key + "'!";

      if (match = didYouMean(key, defaultKeys)) {
        msg += " Did you mean '" + match + "'?";
      }

      throw new PluginError(constants.PLUGIN_NAME, gutil.colors.red(msg));
    }
  }
}
示例#9
0
文件: index.js 项目: Gyyhuan/umi
 Object.keys(config).forEach(key => {
   // 禁用项
   if (disabledConfigs.includes(key)) {
     errorMsg = `Configuration item ${key} is disabled, please remove it.`;
   }
   // 非法的项
   if (!pluginNames.includes(key)) {
     const guess = didyoumean(key, pluginNames);
     const affix = guess ? `do you meen ${guess} ?` : 'please remove it.';
     errorMsg = `Configuration item ${key} is not valid, ${affix}`;
   } else {
     // run config plugin's validate
     const plugin = pluginsMapByName[key];
     if (plugin.validate) {
       try {
         plugin.validate.call(context, config[key]);
       } catch (e) {
         errorMsg = e.message;
       }
     }
   }
 });
示例#10
0
文件: cli.js 项目: Joncy/dashboard
.description('Uninstall an app')
.action(uninstall)

cli.command('stop <app name>')
.description('Stops a running app')
.action(stop)

cli.command('restart <app name>')
.description('Restarts a running app')
.action(restart)

cli.command('launch <app name>')
.description('Launches an installed app')
.action(launch)

cli.parse(process.argv)

// No command specified or unrecognaized command
if (cli.args.length === 0) {
  cli.help()
} else if (ACTIONS_LIST.indexOf(process.argv[2]) === -1) {
  didYouMean.threshold = null
  var matched = didYouMean(process.argv[2], ACTIONS_LIST)
  if (matched != null) {
    console.log('\n\tDid you mean "' + didYouMean(process.argv[2], ACTIONS_LIST) + '"?')
    console.log('\n\tType "beast ' + matched + ' -h" to know its parameters' + '\n')
  } else {
    cli.help()
  }
}