Undefined Title

Python-like idiom for node.js command line

2013-02-22

There is a major idiom in Python for CLI.

if __name__ == '__main__':

This is in order to run the code in the if-clause only from executed on command line.

I’ll show same code like this on node.js.

hello.coffee works as a command and as a library. This provides a method ‘say’ if it’s library.

Here is an idiom for node.js.

if process.argv[1] == __filename