ARG-TO-OBJECT
ATO is a quick-and-dirty argument parser meant for situations when a complicated CLI isn't necessary.
Use process.argv
by default.
const ato = var params = ato
An object can be used for defaults.
// node sample.js -files a b c -r falsevar defaults = files: recursive: true var params = ato /* * { * files: ["a", "b", "c"], * recursive: false * } */
Argument shorthands are expanded by a simple prefix-search
// node sample.js -f a b c -r params = ato /* '-f' extends to 'files' * { files: ["a", "b", "c"], ... } */
Pass in arguments manually.
ato
Without a default object, the parsed object will constructed with _-tak_s as keys.
The arguments -f a b c -r
will yield
f: "a" "b" "c" r: true
Type interpolation examples.
args=-r
result={r: true}
args=-r 1 2 3
result={r: [1, 2, 3]}
args=-r false
result={r: false}
args=-r -f hello
result={r: true, f: 'hello'}