dthree / vorpal

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

Is it possible to use Vorpal outside its own shell? #41

Closed andrerpena closed 8 years ago

andrerpena commented 8 years ago

First. Thanks for this Project. It's awesome. I was wondering if it's possible to run a Vorpal app outside it's own shell. I mean.. directly from the OS. Thanks.

dthree commented 8 years ago

Your welcome and thanks. :)

Do you mean to run it without the node runtime? Could you please clarify a little bit?

andrerpena commented 8 years ago

Thanks for the reply.

Not without the Node.js runtime. I mean, I'm building an app called quotr. When I type quotr, it enters its own shell, in which I can type help and whatever command I implement.

This behavior is cool, but I'm thinking whether it's possible to expose these inner commands to the OS, without the need to type quotr first.

Example: I have a command called snapshot. So, this is what the user does:

user@computer: quotr
quotr$
quotr$ snapshot
You triggered `snapshot`.
quotr$

What I want is:

 user@computer: quotr snapshot
 You triggered `snapshot`.
 user@computer:

Is that possible? Thanks again.

scotthovestadt commented 8 years ago

You might want to look into vorpal.exec, which would allow you to execute a "shell" command in any Node context (without the user manually typing the command into the shell).

andrerpena commented 8 years ago

Thanks for your reply.

Just so I'm clear. What you are saying is that, in my mainApp.js, I can read parameters that the user passed to the app and then "repass" these parameters to vorpal using vorpal.exec?

scotthovestadt commented 8 years ago

Yeah, exactly.

scotthovestadt commented 8 years ago

Vorpal also has the ability to do something like the "repass" automatically, vorpal.parse but I haven't looked into that at all. I'm currently using vorpal.exec for a use-case similar to yours.

andrerpena commented 8 years ago

huumm... that's interesting. So, I supposed that, for this use-case, I'd never do vorpal.show(), I would just "repass" using either parse or exec and then exit.

Thanks @scotthovestadt and @dthree . I appreciate your help.

dthree commented 8 years ago

Sorry just saw this again, and I think I get what you're saying now.

Just use the vorpal.parse(process.argv). That should parse the args and execute automatically.

https://github.com/dthree/vorpal/wiki/API-|-vorpal#vorpalparseargv-options

Does this help?

andrerpena commented 8 years ago

Yes it helps. I really appreciate your help @dthree . o/

dthree commented 8 years ago

Great! And no problem.


This is a really good question, and will undoubtedly come up with others. If you could post it on Stack Overflow as well, that would be very helpful :smiley:

andrerpena commented 8 years ago

@dthree, but what title would I use? If it's the same title and text as this issue, people will find on Google if they search it, wont they? Besides, the question title is too abstract. I think the best approach would be to mention this use-case directly in vorpal's help. People can even opt for using another CLI framework if they judge this is not possible just by looking at the docs.

PS: I've seen you've watched it already but I published the first version of quotr using Vorpal. I mentioned your project in the Third Party section.

Thanks again for the project and your help.

dthree commented 8 years ago

I would call it Invoke a Vorpal.js command from the shell.

Stack overflow is good as it's the number one tech forum on the internet, and the odds of it coming up on a google search over a github issue is about 20 to 1. The problem is covered in the API Docs, just as most problems asked on SO are covered in documentation somewhere. Stack Overflow is good at pointing people to the right docs. I do think it would be very valuable to others to post on SO, but it's up to you!

Yeah - excited about quotr! Thanks for mentioning Vorpal. :+1:

andrerpena commented 8 years ago

Here you go @dthree : http://stackoverflow.com/questions/33489201/is-it-possible-to-create-a-vorpal-application-which-the-commands-output-goes-di

Feel free to answer :)

dthree commented 8 years ago

Haha k thanks.