dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Run validation before any commands start running #100

Open scotthovestadt opened 8 years ago

scotthovestadt commented 8 years ago

Let's say I have the following commands:

file-read test.json | transform | file-write test.csv

In this use-case, let's say I want to validate the file extension before running a command. I add the validate method, but it won't run until after the whole file has been read in and transformed. In my use-case, that may take hours.

I'd like the validation to run immediately before any command starts running.

@dthree Any thoughts?

dthree commented 8 years ago

It should run for a single command. Are you saying that the validate for specifically the piped commands doesn't happen? If so, yeah, that's a bit tricky. You would have to throw it in right around here:

https://github.com/dthree/vorpal/blob/master/lib/vorpal.js#L919

scotthovestadt commented 8 years ago

Thanks for the pointer. I am going to implement this weekend. I need it.

My tool, each command can take several hours - days even. It renders a progress bar... but I really need to validate all commands in advance. Some of the validation involves HTTP calls.

dthree commented 8 years ago

K got it.