1'use strict' 2var aliases = require('../config/cmd-list').aliases 3 4module.exports = function usage (cmd, txt, opt) { 5 var post = Object.keys(aliases).reduce(function (p, c) { 6 var val = aliases[c] 7 if (val !== cmd) return p 8 return p.concat(c) 9 }, []) 10 11 if (opt || post.length > 0) txt += '\n\n' 12 13 if (post.length === 1) { 14 txt += 'alias: ' 15 txt += post.join(', ') 16 } else if (post.length > 1) { 17 txt += 'aliases: ' 18 txt += post.join(', ') 19 } 20 21 if (opt) { 22 if (post.length > 0) txt += '\n' 23 txt += 'common options: ' + opt 24 } 25 26 return txt 27} 28