
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Ncommand是一个控制台交互式命令解析控制器。可以快速便捷的开发一个新的脚手架。
npm i ncommand
var command = require("Ncommand");
new command(Options)
说明:
Optionsc(Object),选填
Optionsc.input {Object|Array},默认为["Commands","Options"],例如:
new command({input:[]})
Optionsc.input[args,...] {String|Object},例如:
new command({input:["name1","name2"]})
new command({input:[{
fnName:"name1",
title:"我是附带说明" //选填
},"name2"]})
//如果更改了默认的Optionsc参数选项的话,那么后面就该调用对应方法,例如:
new command({input:["name1","name2"]}).name1().name2();
new command()
.Commands(param)
//....
.Options(param)
//....
说明:
param {Object},选填,不填就不执行任何事物
param.log {Array},必填,例如:
new command()
.Commands({
log:[args,...]
})
param.output {Boolean},选填,例如:
new command()
.Commands({
//默认为true,如果为true则是打印输出命令,如果为false则不输出命令,
//可以理解成功如果设置为false的话,当前的命令,用户看不到,但它
//又确实存在,所以利用这个字段可实现隐藏命令
output:false
})
param.callback {Function},选填,例如:
new command()
.Commands({
log:["参数A",args,...],
callback:function(agvs,newAgvs){
//这里是当前参数的回调函数
console.log(this);//this是new command()对象,承接上下文
console.log(agvs);//agvs是当前执行参数,即 “ 参数A ”
console.log(newAgvs);//newAgvs是当前执行参数以后的参数,例如: “node test.js 参数A 参数B... ”,即"包含参数B以后的参数"
this
.Commands({
log:["参数B",args,...],
callback:function(agvs,newAgvs,cmdParam){
//这里是当前参数的回调函数
console.log(this);//this是new command()对象,承接上下文
console.log(agvs);//agvs是当前执行参数,即 “ 参数B ”
console.log(newAgvs);//newAgvs是当前执行参数以后的参数,例如: “node test.js 参数A 参数B... ”,即"包含参数B以后的参数"
console.log(cmdParam);//cmdParam是当前命令的有关参数。
//.....可以无限嵌套下去或者执行其他事物
}
})
.init();
//.....可以无限嵌套下去或者执行其他事物
}
})
new command()
.Commands({
log:["参数a"]
})
.init(callback,showCallback);
说明:
callback {Function},选填,例如:
new command()
.Commands({
log:[args,...]
})
.init(function(){
//这是init的回调方法
console.log(this);//this是new command()对象,承接上下文
});
showCallback {Array},选填,例如:
new command()
.Commands({
log:[args,...]
})
.init(new Function,function(){
//帮助的回调方法
console.log(this);//this是new command()对象,承接上下文
});
//备注:如果showCallback传,则不会打印帮助提示信息,等同于你在自定义帮助提示。
// 如果showCallback不传,则会打印帮助提示信息。
// 如果showCallback传null,则会打印帮助提示信息。
// 如果showCallback的返回值为true的话,不结束当前程序,默认为false,即结束当前程序
new command()
.Commands({
log:[args,...]
})
.end(Opt)
.init(callback,showCallback);
说明:
Opt {String|Function},选填,不填插入一行空信息,例如:
new command()
.Commands({
log:[args,...]
})
.end("我是插入信息")
.end(function(){
//这是end的回调方法
console.log(this);//this是new command()对象,承接上下文
//彩色信息输入(如需彩色输入,请参考:https://github.com/zys8119/ncol)
this.console
.red("红色")
.yellow("黄色")
.color(function () {
this
.red(" 哈哈~")
.yellow("哈哈~")
.success("哈哈~")
.info("哈哈~")
})
.success("成功");
})
.init(function(){
//这是init的回调方法
console.log(this);//this是new command()对象,承接上下文
});
var command = require("./index");
new command()
.Commands({
log:["a","这是...red('一')个命令",{},[]],
callback:function () {
this
.Commands({
log:["c","这是a命令下的c命令",{},[]],
callback:function () {
console.log(this)
}
})
.Commands({
log:["-h","这是帮助命令",{},[]],
callback:function () {
console.log(this)
}
})
.init();
}
})
.end("我是插入的信息")
.end(function() {
this.console
.red("红色")
.yellow("黄色")
.color(function () {
this
.red(" 哈哈~")
.yellow("哈哈~")
.success("哈哈~")
.info("哈哈~")
})
.success("成功");
//...
})
.Commands({
log:["b"],
})
.Options({
log:["c"],
callback:function (w,e,cmds) {
this.console.warn("我是当前的argv参数:"+w);
this.console.warn("我是c命令之后的argv参数:"+e);
this.console.warn("我是当前命令的相关参数:"+JSON.stringify(cmds));
}
})
.Options({
log:["d"],
output:false,
callback:function (w,e) {
this.console.warn("我是隐藏命令,我不输出,但我确实存在,哈哈。");
}
})
.init();
FAQs
Ncommand是一个控制台交互式命令解析控制器。可以快速便捷的开发一个新的脚手架。
The npm package ncommand receives a total of 0 weekly downloads. As such, ncommand popularity was classified as not popular.
We found that ncommand demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.