【问题标题】:How to write a NectarJS program that accepts arguments?如何编写一个接受参数的 NectarJS 程序?
【发布时间】:2018-08-17 06:42:27
【问题描述】:

好吧,问题在标题中,所以我要做的只是给你一个例子,希望有人能提供帮助!

注意:我使用的是 Linux Mint 18.x

这是我想做的事情:

#compile the javascrpit code with nectar  
nectar file.js --single -o compiledFile  
#now i want to run it with a second argument witch is an input file  
./compiledFile inputFile  

我知道 JavaScrpit 本身不支持这种类型,但 NectarJS 库/编译器中有类似的东西

【问题讨论】:

    标签: javascript linux compilation arguments nectarjs


    【解决方案1】:

    您现在可以像使用 Node 一样使用 process.argv(使用 nectar cli 指定 --env 节点,或在 std env 中使用 require("process"))

    一个简短的例子:

    for(var i = 0; i < process.argv.length; i++)
    {
      console.log(process.argv[i]);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-01
      • 2016-07-07
      • 1970-01-01
      • 2012-09-08
      • 1970-01-01
      • 2013-08-15
      • 2010-11-05
      • 1970-01-01
      • 2014-12-13
      相关资源
      最近更新 更多