Skip to content

Instantly share code, notes, and snippets.

@hns
Created November 13, 2009 10:51
Show Gist options
  • Save hns/233749 to your computer and use it in GitHub Desktop.
Save hns/233749 to your computer and use it in GitHub Desktop.
helma> var Parser = require('helma/args').Parser;
helma> var p = new Parser();
helma> p.addOption("s", "silent", null, "Ignore errors and warnings")
helma> p.addOption("x", "extend", "FOO", "Extend core functionality using FOO")
helma> p.addOption("v", "verbose", null, "Be verbose")
helma> p.help()
-s --silent Ignore errors and warnings
-x --extend FOO Extend core functionality using FOO
-v --verbose Be verbose
helma> var args = ["-s", "-x", "foo"];
helma> p.parse(args).toSource()
({silent:true, extend:"foo"})
helma> args.toSource()
[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment