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

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.

主站蜘蛛池模板: 石泉县| 高邮市| 简阳市| 吉林市| 堆龙德庆县| 阳江市| 建宁县| 泌阳县| 西乡县| 昂仁县| 平陆县| 东阳市| 芮城县| 东乡族自治县| 苏州市| 永春县| 会宁县| 怀仁县| 宁都县| 天等县| 南汇区| 合川市| 三江| 远安县| 灵璧县| 共和县| 崇信县| 土默特左旗| 平安县| 涞源县| 米脂县| 大关县| 永丰县| 邳州市| 韶山市| 连云港市| 泗阳县| 高碑店市| 论坛| 望都县| 阳朔县|