简体   繁体   English

Node.js的命令行界面

[英]Command line interface with Node.js

I am creating command line interface by using node.js. 我正在使用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. 例如,当我从列表中选择“ Show user profile资料”时,它将显示用户详细信息。 Now, I exit from app(not from the cli console). 现在,我从应用程序退出(而不是从cli控制台退出)。 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. 我正在使用Inquirer作为用户输入,使用Commander作为帮助并请求 HTTP操作。 I can share my code if needed. 如果需要,我可以共享我的代码。

Vorpal.js was made to solve this exact problem. 制作Vorpal.js就是为了解决这个确切的问题。 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. 它的工作原理和感觉几乎与Commander完全相同,但是命令结束后,您无需退出应用程序-它会将您带到您创建的交互式CLI环境中。 It uses Inquirer for its prompts. 它使用Inquirer作为提示。

Disclaimer: I wrote Vorpal.js 免责声明:我写了Vorpal.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM