#!/usr/bin/env node require('lego-colorful').colorful(); var commander = require('commander'); var log = require('lego-log'); var print = require('../lib/utils/print'); var search = require('../lib/client').search; commander .usage('[options] ') .option('-r, --registry ', 'registry url of yuan server') .option('--verbose', 'show more log') .option('--no-color', 'disable colorful print'); commander.on('--help', function() { console.log(); console.log(' ' + 'Examples:'.to.bold.blue); console.log(); console.log(' $', 'lego search'.to.magenta.color, 'dom'); console.log(); }); commander.parse(process.argv); if (!commander.args[0]) { process.stdout.write(commander.helpInformation()); commander.emit('--help'); process.exit(); } console.log(); log.config(commander); search({ name: commander.args[0], registry: commander.registry }, function(err, body) { if (err) { log.error('exit', err.message); process.exit(2); } console.log(' ', (body.data.total + ' results').to.bold.color); console.log(''); var arr = body.data.results; arr.forEach(function(pkg) { print(pkg, commander); console.log(''); }); });