CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
index.js28 linesDownload Raw Back to help
1var fs = require('fs');2var path = require('path');3const supportsColor = require('supports-color');4 5module.exports = help;6 7const highlight = supportsColor.stdout ? '\x1B\[$1m' : '';8 9function help(item) {10  if (!item) {11    item = 'help';12  } else if (item === true) { // if used with -h or --help and no args13    item = 'help';14  }15 16  // cleanse the filename to only contain letters17  // aka: /\W/g but figured this was eaiser to read18  item = item.replace(/[^a-z]/gi, '');19 20  try {21    var dir = path.join(__dirname, '..', '..', 'doc', 'cli', item + '.txt');22    var body = fs.readFileSync(dir, 'utf8');23    return body.replace(/\\x1B\[(.)m/g, highlight);24  } catch (e) {25    return '"' + item + '" help can\'t be found';26  }27}28