0

I want to do some local node test before push the code to server.

how can I read terminal input as a input for my js script? readline or something

1
  • 1
    Show us what you have done. Commented Jun 4, 2017 at 11:30

2 Answers 2

1

I think there is no need to use third party library, if you just want to get command line params.

You can use process.argv property of process node core object.

just use process.argv & you are good to go.It returns an array in which by default there is 2 element, at 0 index Node execution directory & at 1 index working directory, so cmd line params start from 2nd index.

So in nutshell, you can access cmd line params using process.argv[2] onwards.

Sign up to request clarification or add additional context in comments.

Comments

0

For commandline app you can use nicl. you can make call to your chat module or websocket or whatever based on your logic.

var nicl = require("nicl");

function main() {
    nicl.printLine("Hello, what is your name?");
    var name = nicl.readLine();
    //call to websocket or any chat module 
    nicl.printLine("Great to meet you, " + name + "!");


    process.exit(0);
}

nicl.run(main);

1 Comment

thank you for your answer! My problem is that I need to make a chat with terminal - input, feedback, feedback as further input as so on... how can I do that?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.