赞
踩
外卖返利cps分销系统每日领卷美团优惠券红包流量小程序搭建源码
'use strict' const inspect = require('util').inspect const isPromise = require('./is-promise') const { applyMiddleware, commandMiddlewareFactory } = require('./middleware') const path = require('path') const Parser = require('yargs-parser') const DEFAULT_MARKER = /(^\*)|(^\$0)/ // handles parsing positional arguments, // and populating argv with said positional // arguments. module.exports = function command (yargs, usage, validation, globalMiddleware) { const self = { } let handlers = { } let aliasMap = { } let defaultCommand globalMiddleware = globalMiddleware || [] self.addHandler = function addHandler (cmd, description, builder, handler, commandMiddleware) { let aliases = [] const middlewares = commandMiddlewareFactory(commandMiddleware) handler = handler || (() => { }) if (Array.isArray(cmd)) { aliases = cmd.slice(1) cmd = cmd[0] } else return visited } require('require-directory')({ require: req, filename: callerFile }, dir, opts) } // lookup module object from require()d command and derive name // if module was not require()d and no name given, throw error function moduleName (obj) { const mod = require('which-module')(obj) if (!mod) throw new Error(`No command name given for module: ${inspect(obj)}`) return commandFromFilename(mod.filename) } // derive command name from filename function commandFromFilename (filename) { return path.basename(filename, path.extname(filename)) } function extractDesc (obj) { for (let keys = ['describe', 'description', 'desc'], i = 0, l = keys.length, test; i < l; i++) { test = obj[keys[i]] if (typeof test === 'string' || typeof test === 'boolean') return test } return false } self.parseCommand = function parseCommand (cmd) { const extraSpacesStrippedCommand = cmd.replace(/\s{ 2,}/g, ' ') const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/) const bregex = /\.*[\][<><
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。