1 Star 0 Fork 0

animalcoder/Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
arg.js 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
animalcoder 提交于 2020-03-17 14:52 +08:00 . Vueinit
'use strict';
const
CoaParam = require('./coaparam'),
chalk = require('chalk');
/**
* Argument
*
* Unnamed entity. From command line arguments passed as list of unnamed values.
*
* @class Arg
* @extends CoaParam
*/
module.exports = class Arg extends CoaParam {
/**
* @constructs
* @param {COA.Cmd} cmd - parent command
*/
constructor(cmd) {
super(cmd);
this._cmd._args.push(this);
}
_saveVal(args, val) {
this._val && (val = this._val(val));
const name = this._name;
this._arr
? (args[name] || (args[name] = [])).push(val)
: (args[name] = val);
return val;
}
_parse(arg, args) {
return this._saveVal(args, arg);
}
_checkParsed(opts, args) {
return !args.hasOwnProperty(this._name);
}
_usage() {
const res = [];
res.push(chalk.magentaBright(this._name.toUpperCase()), ' : ', this._title);
this._req && res.push(' ', chalk.redBright('(required)'));
return res.join('');
}
_requiredText() {
return `Missing required argument:\n ${this._usage()}`;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/animalcoder/Vue.git
git@gitee.com:animalcoder/Vue.git
animalcoder
Vue
Vue
master

搜索帮助