Get Node.js Command Line Arguments with yargs
Using command line arguments within Node.js apps is par for the course, especially when you're like me and you use JavaScript to code tasks (instead of bash scripts). Node.js provides process.argv
but that doesn't provide a key: value
object like you'd expect:
/*
$ node myscript.js --key1=value1 --key2=value2
[ 'node',
'/path/to/myscript.js',
'--key1=value1',
'--key2=value2' ]
*/
Bleh. If you want to work with a sane API for command line arguments, use yargs:
// Get the yargs resource
var yargs = require('yargs').argv;
// Check for arguments
if(yargs.someKey === expectedValue) {
// Do whatever
}
/*
yargs = {
key1: value1
key2: value2
};
*/
yargs provides a key:value
object for arguments instead of the native process.argv
mess. No hassle, no fuss, just access to command line arguments with a logical API. Happy noding!
One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating:
new Element Madness
The first way to create UI-driven...
My team mate Edna Piranha is not only an awesome hacker; she's also a fantastic philosopher! Communication and online interactions is a subject that has kept her mind busy for a long time, and it has also resulted in a bunch of interesting experimental projects...
It goes without saying but MooTools' inheritance pattern allows for creation of small, simple classes that possess immense power. One example of that power is a class that inherits from Request, Request.JSON, and Request.JSONP: Request.Stocks. Created by Enrique Erne, this great MooTools class acts as...
As much as developers now loathe Flash, we're still playing a bit of catch up to natively duplicate the animation capabilities that Adobe's old technology provided us. Of course we have canvas, an awesome technology, one which I highlighted 9 mind-blowing demos. Another technology available...
[pirateAccent]Yaaaarrrrrg!![/pirateAccent]