Reputation: 4017
I am creating command line interface by using node.js. It has login feature and after login, needs to show output based on user selection from list. Problem i'm facing is it exits from the node after first result. It's asking login again. It should not exit, if exit from app also fine but, still i should able to fetch the logged in user detail. Say example it displays user details when I selects Show user profile
from the list. Now, I exit from app(not from the cli console). Again i have to login to see other result. Instead of that can we maintain any session kind of thing for the logged in user so that we can allow user to enter into system without login again and again. Or suggest me any other solution to do this. !
Sorry for my bad English. Hope you understand my problem. (attached an image)
I am using inquirer for user inputs, commander for help and request for HTTP operations. I can share my code if needed.
Upvotes: 3
Views: 1184
Reputation: 20730
Vorpal.js was made to solve this exact problem. It works and feels almost exactly like Commander, however once the command ends, you don't exit the app - it drops you into an interactive CLI environment that you create. It uses Inquirer for its prompts.
Disclaimer: I wrote Vorpal.js
Upvotes: 3