Closed albacoretuna closed 7 years ago
Hi @omidfi. Here's an example. Check out .command.allowUnknownOptions() docs for more details.
// index.js
var vorpal = require('vorpal')()
vorpal
.command('post <url>')
.description('post stuff to url')
.allowUnknownOptions()
.action(function(args){
console.log(args)
});
vorpal.exec("post localhost:3000/user/all --Authorization 'Bearer long token' --AnotherHeader 'blahblahbla' --someData 'blahBlah'")
$ node index.js
{ options:
{ Authorization: 'Bearer long token',
AnotherHeader: 'blahblahbla',
someData: 'blahBlah' },
url: 'localhost:3000/user/all' }
Hi thanks for the nice project :)
I'm making an http cli tool and I need to be able to parse commands like this:
How can I approach this with vorpal? I tried using variadic arguments, but it didn't help as the headers are also variadic. I also tried to use a variadic option, so that after --header I could add multiple items, but that didn't work either.