cli.js 440 B

12345678910111213141516171819202122
  1. #!/usr/bin/env node
  2. var errno = require('./')
  3. , arg = process.argv[2]
  4. , data, code
  5. if (arg === undefined) {
  6. console.log(JSON.stringify(errno.code, null, 2))
  7. process.exit(0)
  8. }
  9. if ((code = +arg) == arg)
  10. data = errno.errno[code]
  11. else
  12. data = errno.code[arg] || errno.code[arg.toUpperCase()]
  13. if (data)
  14. console.log(JSON.stringify(data, null, 2))
  15. else {
  16. console.error('No such errno/code: "' + arg + '"')
  17. process.exit(1)
  18. }