function helpCategoriesSummary(root) { var categories = []; function scan(parent, each) { for (var name in parent.categories) { var cat = parent.categories[name]; each(cat); scan(cat, each); } } scan(root, function (cat) { categories.push(cat); }); var maxLength = 14; categories.forEach(function (cat) { if (maxLength < cat.fullName().length) maxLength = cat.fullName().length; }); log.help(''); log.help('Commands:'); categories.forEach(function (cat) { var name = cat.fullName(); while (name.length < maxLength) { name += ' '; } log.help(' ' + name + ' ' + cat.description().cyan); }); }
help.show = function (name, action) { var usage, resource = jitsu.commands.commands[name]; if (typeof resource !== 'function') { if (action && !resource[action]) { winston.error('No help for command ' + [name, action].join(' ').magenta); return; } usage = action ? resource[action].usage : resource.usage; if (!usage) { winston.error('No help for command ' + [name, action].join(' ').magenta); return; } } else { usage = resource.usage; } winston.help(''); usage.forEach(function (line) { winston.help(line); }); winston.help(''); };
commandHelpInformation: function() { var self = this; log.help(self.description()); log.help(''); log.help('Usage:', self.fullName() + ' ' + self.usage()); self.helpOptions(); return ''; },
parts.push(function (err, shallow, skip) { if (err && shallow && !skip) { winston.help(''); winston.help('Usage:'.cyan.bold.underline); command.usage.forEach(function (line) { winston.help(line); }); winston.help(''); } callback(err, shallow); });
helpOptions: function(cmdExtra) { var self = this; var revert = self.options; if (cmdExtra) { self.options = self.options.concat(cmdExtra.options); } log.help(''); log.help('Options:'); self.optionHelp().split('\n').forEach(function (line) { log.help(' ', line); }); self.options = revert; }
function helpOptions(cmd, cmdExtra) { var revert = cmd.options; if (cmdExtra) { cmd.options = cmd.options.concat(cmdExtra.options); } cmd.options = cmd.options.filter(function (option) { return option.long != '--powershell'; }); log.help(''); log.help('Options:'); cmd.optionHelp().split('\n').forEach(function (line) { log.help(' ', line); }); cmd.options = revert; }
jitsu.apps.list(username, function (err, apps) { if (err) { console.log(err); return callback(err); } if (!apps || apps.length === 0) { winston.warn('No applications exist.'); winston.help('Try creating one with ' + 'jitsu apps create'.magenta); return callback(); } var rows = [['name', 'state', 'subdomain', 'start', 'latest']], colors = ['underline', 'underline', 'underline', 'underline', 'underline']; apps.forEach(function (app) { rows.push([ app.name, app.state || 'stopped', app.subdomain, app.scripts.start || '---', app.snapshots && app.snapshots.length > 0 ? app.snapshots[app.snapshots.length - 1].filename : '---' ]); }); jitsu.log.putRows('data', rows, colors); callback(); });
}, function (err, res, body) { if (!responded) { responded = true; try { var pkg = JSON.parse(body); if (semver.gt(pkg.version, jitsu.version)) { winston.warn('A newer version of ' + 'jitsu'.magenta + ' is available. ' + 'You should update immediately.'); winston.help('To install the latest ' + 'jitsu'.magenta + ' type `[sudo] npm install jitsu -g`'); winston.warn('If you wish to ' + 'continue'.bold + ' without an update you must ' + 'type'.cyan + ' ' + '\'yes\''.magenta); var question = [{ message: 'Continue without updating? Bad things might happen (no)', name: 'ignore' }]; jitsu.prompt.get(question, function(err, result) { if (err) return callback(); callback(result.ignore !== 'yes'); }); } else { callback(); } } catch (ex) { // // Ignore errors from GitHub. We will notify the user // of an upgrade at the next possible opportunity. // callback(); } } });
categories.forEach(function (cat) { var name = cat.fullName(); while (name.length < maxLength) { name += ' '; } log.help(' ' + name + ' ' + cat.description().cyan); });
function helpCategories(parent) { for (var name in parent.categories) { var cat = parent.categories[name]; log.help(''); log.help(cat.description().cyan); for (var index in cat.commands) { var cmd = cat.commands[index]; log.help(' ', cmd.fullName() + ' ' + cmd.usage()); } helpCategories(cat); for (var subCat in cat.categories) { helpCategories(cat.categories[subCat]); //log.help(' ', cat.categories[subCat].fullName() + ' ...'); } } }
function categoryHelpInformation() { if (cli.powershell) { log.help('\n'); } log.help(this.description()); helpCommands(this); helpCategories(this); helpOptions(this); if (cli.powershell) { log.help('\n'); } return ''; }
function commandHelpInformation() { if (cli.powershell) { log.help('\n'); } log.help(this.description()); log.help(''); log.help('Usage:', this.fullName() + ' ' + this.usage()); helpOptions(this, cli); if (cli.powershell) { log.help('\n'); } return ''; }
helpCategories: function(levels) { for (var name in this.categories) { var cat = this.categories[name]; log.help(''); log.help(cat.description().cyan); if (levels === -1 || levels > 0) { for (var index in cat.commands) { var cmd = cat.commands[index]; log.help(' ', cmd.fullName() + ' ' + cmd.usage()); } cat.helpCategories(levels !== -1 ? --levels : -1); } else { log.help(' ', cat.fullName()); } } },
helpInformation: function() { var self = this; if (!self.parent) { var args = process.argv.slice(0, 2); var raw = self.normalize(process.argv.slice(2)); var packagePath = path.join(__dirname, '../package.json'); var packageInfo = JSON.parse(fs.readFileSync(packagePath)); if (raw.indexOf('-v') >= 0) { console.log(packageInfo.version); } else if (raw.indexOf('--version') >= 0) { console.log(util.format('%s (node: %s)', packageInfo.version, process.versions.node)); } else { self.setupCommand(args, raw, true); if (log.format().logo === 'on') { log.info(' _ _____ _ ___ ___'.cyan); log.info(' /_\\ |_ / | | | _ \\ __|'.cyan); log.info(' _ ___'.grey + '/ _ \\'.cyan + '__'.grey + '/ /| |_| | / _|'.cyan + '___ _ _'.grey); log.info('(___ '.grey + '/_/ \\_\\/___|\\___/|_|_\\___|'.cyan + ' _____)'.grey); log.info(' (_______ _ _) _ ______ _)_ _ '.grey); log.info(' (______________ _ ) (___ _ _)'.grey); log.info(''); } log.info('Windows Azure: Microsoft\'s Cloud Platform'); log.info(''); log.info('Tool version', packageInfo.version); self.helpCommands(); self.helpCategoriesSummary(self.showMore()); self.helpOptions(); } } else { log.help(self.description()); log.help(''); log.help('Usage:', self.fullName() + ' ' + self.usage()); self.helpOptions(); } return ''; },
categoryHelpInformation: function() { var self = this; log.help(self.description()); self.helpCommands(); self.helpCategories(-1) ; self.helpOptions(); return ''; },
helpCategoriesSummary: function(showMore) { var categories = []; function scan(parent, levels, each) { for (var name in parent.categories) { var cat = parent.categories[name]; each(cat); if (levels === -1 || levels > 0) { scan(cat, levels !== -1 ? --levels : -1, each); } } } scan(this, showMore ? -1 : 0, function (cat) { categories.push(cat); }); var maxLength = 14; // Sort categories by alphabetical order categories.sort(function (a, b) { return (a.fullName() < b.fullName()) ? -1 : (a.fullName() > b.fullName()) ? 1 : 0; }); categories.forEach(function (cat) { if (maxLength < cat.fullName().length) maxLength = cat.fullName().length; }); log.help(''); log.help('Commands:'); categories.forEach(function (cat) { var name = cat.fullName(); while (name.length < maxLength) { name += ' '; } log.help(' ' + name + ' ' + cat.description().cyan); }); },
findit.sync(path.resolve(smith.src + '/../authors')).forEach( function (file) { var ext = path.extname(file); if ( ext == '.json' ) { var author = new nconf.Provider(), id; author.use("file", { file: file }); id = author.get("_id"); if (typeof id !== "string") { winston.error("Error processing "+file.yellow); winston.help("Missing or malformed _id field"); return; } authors[author.get("_id").trim()] = author; } });
function rootHelpInformation() { var args = process.argv.slice(0, 2); var raw = cli.normalize(process.argv.slice(2)); setupCommand(args, raw); if (cli.powershell) { log.info('\n'); } if (log.format().logo === 'on') { log.info(' _ _____ _ ___ ___'.cyan); log.info(' /_\\ |_ / | | | _ \\ __|'.cyan); log.info(' _ ___'.grey + '/ _ \\'.cyan + '__'.grey + '/ /| |_| | / _|'.cyan + '___ _ _'.grey); log.info('(___ '.grey + '/_/ \\_\\/___|\\___/|_|_\\___|'.cyan + ' _____)'.grey); log.info(' (_______ _ _) _ ______ _)_ _ '.grey); log.info(' (______________ _ ) (___ _ _)'.grey); log.info(''); } var packagePath = path.join(__dirname, '../../package.json'); var packageInfo = JSON.parse(fs.readFileSync(packagePath)); log.info('Windows Azure: Microsoft\'s Cloud Platform'); log.info(''); log.info('Tool version', packageInfo.version); helpCommands(this); helpCategoriesSummary(this); helpOptions(this); if (cli.powershell) { log.help('\n'); } return ''; }
command.usage.forEach(function (line) { winston.help(line); });
cmd.optionHelp().split('\n').forEach(function (line) { log.help(' ', line); });
parent.commands.forEach(function (cmd) { log.help(''); log.help(cmd.description().cyan); log.help(' ', cmd.fullName() + ' ' + cmd.usage()); });
jitsu.setupUser = function (callback) { winston.warn('You will need to login to continue'); winston.info('To login, you will need an activated nodejitsu account'); winston.help('You can create an account using the ' + 'jitsu signup'.magenta + ' command'); jitsu.setupUserNoWarn(callback); };