Skip to content
Advertisement

How to write a NectarJS program that accepts arguments?

Well,the question is in the title, so what i am going to do is just give you an example and hopefully someone can help!

Note: I am using Linux Mint 18.x

Here is what i want to be able to do:

#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  

I know that JavaScrpit itself doesn’t support that kind of a ting but is there something similar in the NectarJS library/compiler

Advertisement

Answer

You can now use process.argv like with Node (specify –env node with nectar cli, or require(“process”) in std env)

a short example :

for(var i = 0; i < process.argv.length; i++)
{
  console.log(process.argv[i]);
}
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement