admin管理员组文章数量:1356768
When you create Vorpal application, at least from what I see in the docs, it creates it's own shell. First, you enter that shell, and then you start executing mands. Like this:
user@puter: quotr
quotr$
quotr$ snapshot
You triggered `snapshot`.
quotr$
In the above example, the snapshot
mand is being executed "inside" the Vorpal shell. It's output doesn't go directly to the terminal.
What I'm looking for is something like this:
user@puter: quotr snapshot
You triggered `snapshot`.
user@puter:
How can I achieve that with Vorpal?
When you create Vorpal application, at least from what I see in the docs, it creates it's own shell. First, you enter that shell, and then you start executing mands. Like this:
user@puter: quotr
quotr$
quotr$ snapshot
You triggered `snapshot`.
quotr$
In the above example, the snapshot
mand is being executed "inside" the Vorpal shell. It's output doesn't go directly to the terminal.
What I'm looking for is something like this:
user@puter: quotr snapshot
You triggered `snapshot`.
user@puter:
How can I achieve that with Vorpal?
Share Improve this question asked Nov 2, 2015 at 23:58 Andre PenaAndre Pena 59.5k53 gold badges210 silver badges257 bronze badges1 Answer
Reset to default 14Yes, you can do this with the vorpal.parse
method, which will parse the arguments passed into Vorpal and execute them.
var vorpal = require('vorpal')();
vorpal
.mand('snapshot')
.action(function (args, cb) {
this.log('You triggered `snapshot`.');
cb();
});
vorpal.parse(process.argv);
You can have the app exit after pleting the mand simply by omitting vorpal.show()
. Because there is no prompt, Node realizes there is nothing left to do, and the process will exit naturally.
本文标签:
版权声明:本文标题:javascript - Is it possible to create a Vorpal application which the command's output goes directly to the terminal, ins 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743965008a2569722.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论