官术网_书友最值得收藏!

Accessing the command-line argument for the notes application

Let's access the command-line argument in the array now. We'll make a variable called command, and set it equal to process.argv, and we'll grab the item in the third position (which is list, as shown in the preceding command output), which is the index of two as shown here:

var command = process.argv[2];

Then we can log that out to the screen by logging out command the string. Then, as the second argument, I'll pass in the actual command that was used:

console.log('Command: ' , command);

And this is just a simple log to keep track of how the app is getting executed. The cool stuff is going to come when we add if statements that do different things depending on that command.

主站蜘蛛池模板: 汽车| 温州市| 田林县| 察哈| 金阳县| 浦城县| 涟水县| 松溪县| 黔南| 遂溪县| 浑源县| 赫章县| 枣庄市| 江川县| 高安市| 磐安县| 新竹县| 拉孜县| 即墨市| 壤塘县| 江华| 德格县| 鄄城县| 盐边县| 富蕴县| 巨野县| 永川市| 昌江| 敦煌市| 轮台县| 留坝县| 叙永县| 东安县| 南乐县| 平阳县| 北川| 赤城县| 安庆市| 化德县| 福海县| 海阳市|