-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Goals
- Parse a final (immutable) string and take action accordingly
- Keep the process open (including on
-hand-v, and even on incorrect input) - Use commander.js as a library (will get called sometimes later, triggered by events)
Edit:
Goals continuation:
- Get the output from
-vand-hinto a string instead of into the terminal
Use case
A bot which should listen for new messages in a live-chat channel.
Upon the arrival of a new message, it will look for a specific prefix, then send the command to commander.js to be parsed, and will take action accordingly.
Notice: The bot itself runs on a server in an automated manner and doesn't need nor expect any command-line arguments. The goal here is to parse several commands without the node process exiting because commander.js feels like it.
When a prefix -v comes along, it should respond. And it does - great!
But now my bot has made a clean exit.
Turns out commander.js decides when my app is done executing.
This behaviour is, of course, unacceptable, as the next user typing prefix -v into the chat will wait forever, for the bot is now shut down.
The fact that the bot needs to be reconnected to the chat-API and a database every time it starts doesn't make this situation easier.
TL;DR
How does one parse multiple commands without having their app shut down in between?
How to get the output from -v and -h into a string instead of into the terminal?
PS: #443 Talks about something somewhat-related