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

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.

主站蜘蛛池模板: 东光县| 都匀市| 准格尔旗| 珠海市| 苍梧县| 东至县| 新巴尔虎左旗| 尚志市| 黔西县| 柘荣县| 深州市| 库尔勒市| 镇雄县| 斗六市| 华安县| 民丰县| 石城县| 孟津县| 文山县| 安新县| 武邑县| 交口县| 华安县| 保康县| 峨眉山市| 唐山市| 信宜市| 子长县| 绥德县| 志丹县| 黎平县| 美姑县| 内江市| 溆浦县| 信宜市| 汤阴县| 和林格尔县| 丰都县| 阳江市| 延寿县| 台南市|