#!/usr/bin/env node /** * Main we cli commands file */ // Module dependencies const _ = require('lodash'), program = require('./_commander'), package = require('../package.json'), helpers = require('../lib/helpers.js'); program.version(package.version, '-v, --version'); // // Normalize version argument, i.e. // // $ we -v // $ we -V // $ we --version // $ we version // // make `-v` option case-insensitive process.argv = _.map(process.argv, (arg)=> { return (arg === '-V') ? '-v' : arg; }); // $ we version (--version synonym) program .command('version') .description('Show we.js cli version') .action(program.versionInformation); // 404 program .command('*') .description(' ') .action(function unknownOption() { console.error('Command not found: ', program.args[0]); console.error('Use "we" command to show all avaible commands'); } ); const commands = { cli: helpers.loadCLICommands(), project: helpers.loadProjectCommands(), plugins: helpers.loadProjectPluginsCommands() }; helpers.runCommandFNs(commands, program); program.parse(process.argv); let NO_COMMAND_SPECIFIED = program.args.length === 0; if (NO_COMMAND_SPECIFIED) { program.usageMinusWildcard(); }