Node.js 中是否有用于从命令行获取用户输入的模块?
首先:我的意思不是解析 process.argv 数组中的参数和选项,而是提示用户并处理输入/输出。我浏览了 Node.js 官方模块列表,但没有找到任何以下部分或小节提到输入。事实上,在该页面上搜索“输入”只会得到 1 个与 YAML 有关的结果。
不管怎样,我认为 cli 输入应该是异步的,并且在使用 stdin.on('data') 之前我已经解决了这个问题,至少可以说这是很混乱的。对于节点模块来说,这似乎是一个完美的任务,它可能附带额外的好处,例如进度条、旋转器、彩色输出、输入验证等。
可能有一些模块可以做到这一点,但我找不到其中任何一个。
帮助!!
(澄清一下,我需要的唯一功能是简化处理用户输入)
First of all: I don't mean parsing arguments and options from the process.argv
array, but prompting the user and handling input/output. I've looked through the Node.js official module list without finding any sections or subsections that mentions input. In fact a search for 'input' on that page only gets 1 result which has something to do with YAML.
Anyway, I suppose cli input should be asynchronous and I've solved this issue before using stdin.on('data')
which was messy to say the least. This seems like a perfect task for a node module which could come with extra goodies such as progress bars, spinners, coloured output, input validation etc.
There probably are some modules out there that does this, but I can't find any of them.
Help!!
(To clarify, the only functionality I require is the simplification of handling user input)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里搜索模块:http://eirikb.github.com/nipster/
另外,如果你想编写自己的:http://nodejs.org/docs/latest/api/all.html#readline< /a>
#node.js
IRC 欢迎您:http://webchat.freenode.net/?channels=node.jsSearch for modules here: http://eirikb.github.com/nipster/
Also, if you want to write your own: http://nodejs.org/docs/latest/api/all.html#readline
#node.js
IRC welcomes you: http://webchat.freenode.net/?channels=node.js