#!/usr/bin/env node const mri = require('mri') const chalk = require('chalk') const list = require('./list.js') const why = require('npm-why/cli-main.js') const help = ` ${chalk.bold('nls')} - Missing inspector for npm packages. Usage $ nls [] ${chalk.dim('List available npm scripts.')} $ nls why ${chalk.dim('Identifies why a package has been installed.')} Options -h, --help ${chalk.dim('Output usage information')} -v, --version ${chalk.dim('Output the version number')} Examples # List npm scripts in current dir $ ${chalk.green('nls')} # List npm scripts in "node_modules/chalk" $ ${chalk.green('nls node_modules/chalk')} # Find who depend upon package 'chalk'. $ ${chalk.green('nls why chalk')} ` const args = mri(process.argv.slice(2), { boolean: ['help', 'version', 'why'], alias: { h: 'help', v: 'version', w: 'why' } }) if (args.help) { console.info(help) } else if (args.version) { console.info(require('../package.json').version) } else if (args._[0] === 'why' && args._.length === 2) { why(process.cwd(), args._[1]) } else { list() }