Closed ghost closed 7 years ago
vorpal.command
already takes a string as argument. What would be the content of your json file ?
`vorpal.command(["nano", "mkdir", "wget"]).action(function(args,callback){
console.log("it works.")
})
` use any of those commands to execute the same block of code without having to write it out again.
@ozzie1998 you can achieve it similar to this using .alias()
vorpal
.command('test', 'make it work')
.alias(['nano', 'mkdir', 'wget'])
.action(function (args) {
console.log('it works')
})
On Sat, 25 Feb 2017 at 8:12 am, Artem Kostiuk notifications@github.com wrote:
@ozzie1998 https://github.com/ozzie1998 you could do similar tothis using .alias() https://github.com/dthree/vorpal/wiki/api-%7C-vorpal.command#commandaliasname-names
vorpal .command('test', 'make it work') .alias(['nano', 'mkdir', 'wget']) .action(function (args) { console.log('it works') })
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dthree/vorpal/issues/214#issuecomment-282468852, or mute the thread https://github.com/notifications/unsubscribe-auth/AGptNTir3zg2t5nwUz69c0Lyz8UtjwtYks5rf-JSgaJpZM4MKPMy .
This is for an app I'm working on where the user can provide their own commands, that would not work.
I'm out of your app context, but aliases seem to fit your need.
When you need to use single string for command - just pass it to
vorpal.command()
. On the other hand, when you want to use an array, you
can put its first element in vorpal.command()
and rest of elements into
alias()
.
@ozzie1998 This won't work as commands support patterns for arguments, which in turn would make no sense for other items in the array. Use alias
instead.
The commands need to be custom set, alias would not allow that. added or deleted.
On Thu, May 25, 2017 at 7:55 AM, Miles Johnson notifications@github.com wrote:
Closed #214 https://github.com/dthree/vorpal/issues/214.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dthree/vorpal/issues/214#event-1096832892, or mute the thread https://github.com/notifications/unsubscribe-auth/AGptNQ6wZH4QEfvZFvc_jSRYEeQLrbMGks5r9SXVgaJpZM4MKPMy .
@ozzie1998 That doesn't make much sense, as calling command
or alias
would happen in the same scope. Do you have an example?
example,
vorpal.command(CommandString)//etc
where CommandString is a string, or the result of json.stringifying the contents of a json file. Would be really useful.