Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

my-program.js 1.0KB

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env node
  2. //process.env.DEBUG_NOPT = 1
  3. // my-program.js
  4. var nopt = require("../lib/nopt")
  5. , Stream = require("stream").Stream
  6. , path = require("path")
  7. , knownOpts = { "foo" : [String, null]
  8. , "bar" : [Stream, Number]
  9. , "baz" : path
  10. , "bloo" : [ "big", "medium", "small" ]
  11. , "flag" : Boolean
  12. , "pick" : Boolean
  13. }
  14. , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
  15. , "b7" : ["--bar", "7"]
  16. , "m" : ["--bloo", "medium"]
  17. , "p" : ["--pick"]
  18. , "f" : ["--flag", "true"]
  19. , "g" : ["--flag"]
  20. , "s" : "--flag"
  21. }
  22. // everything is optional.
  23. // knownOpts and shorthands default to {}
  24. // arg list defaults to process.argv
  25. // slice defaults to 2
  26. , parsed = nopt(knownOpts, shortHands, process.argv, 2)
  27. console.log("parsed =\n"+ require("util").inspect(parsed))