[nodejs] commander库

nodejs里的commander库可以方便的帮你写一个命令行程序.

program = require 'commander'
program
  .version("0.0.1")
  .option('-v --version', 'version info')

console.log '0.0.1' if program.version?

 上面的脚本是用CoffeeScript写的,
运行`coffee test.coffee -v`后就会输出 -- ‘0.0.1’

原文地址:https://www.cnblogs.com/buhaiqing/p/2867841.html