https://github.com/plotdb/args
argument parser
https://github.com/plotdb/args
Last synced: 29 days ago
JSON representation
argument parser
- Host: GitHub
- URL: https://github.com/plotdb/args
- Owner: plotdb
- License: isc
- Created: 2026-01-23T01:32:19.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2026-01-23T01:49:38.000Z (4 months ago)
- Last Synced: 2026-01-23T18:48:21.506Z (4 months ago)
- Language: LiveScript
- Size: 52.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @plotdb/args
Simple argument parser.
Usage:
require("@plotdb/args")
result = args({
meta: {
file: {alias: "f", type: "string", desc: "filename"},
count: {alias: "c", type: "number", desc: "loop count"},
verbose: {alias: "v", type: "boolean", desc: "verbose for debugging"},
},
onerror: function(e) { process.exit(); }
});
opt = result.options;
console.log(
opt.file, opt.f,
opt.count, opt.count,
opt.verbose, opt.v
);
## Options
You can pass meta directly to args for simplicity:
args({
file: {alias: "f", type: "string", desc: "filename"},
count: {alias: "c", type: "number", desc: "loop count"},
verbose: {alias: "v", type: "boolean", desc: "verbose for debugging"},
})
`@plotdb/args` recognize `meta` property in the given object to determine if it's a simplified parameter. When `meta` is given, you can specify more options:
args({
meta: { file: {...}, count: {...}, ...},
argv: ...
onerror: ...
})
where:
- `argv`: an alternative array of arguments to parse. default `process.argv` when omitted.
- `onerror`: callback when parsing failed. silent exited (`process.exit()`) when omitted.
## License
MIT