v6.0.0-beta1
๐ฆ Super handy cli argument parser with automate generation `--help` flag.
Repository
Current version released
2 years ago
Dependencies
std
Allo Arguments for Deno ๐ฆ
A library for Deno that parses the terminalโs input parameters.
It allows you to assign default values to them, process them and automatically generate a message for --help
.
Example
import { join } from "https://deno.land/std/path/mod.ts";
import { Arguments, ExpectedException } from "https://deno.land/x/allo_arguments/mod.ts";
function getArguments() {
const args = new Arguments({
...Arguments.createHelp(),
myString: {
shortName: 's',
description: 'This is a string flag.',
convertor: Arguments.stringConvertor,
},
myNumber: {
shortName: 'n',
description: 'This is a number flag.',
convertor: Arguments.numberConvertor,
},
myBoolean: {
shortName: 'b',
description: 'This is a boolean flag.',
convertor: Arguments.booleanConvertor,
},
myCustom: {
shortName: 'c',
description: 'This is a custom flag.',
convertor: value => {
if (value === undefined) return undefined;
return `๐ฐ โ ${value} โ ๐ญ`;
},
},
})
.setDesciprion("This is a demo of the arguments library.")
// Important for `--help` flag works.
if (args.isHelpRequested()) args.triggerHelp();
return args.getFlags();
}
try {
const args = getArguments();
console.log(args);
} catch (error) {
Arguments.rethrowUnprintableException(error);
}
Documentation ๐
Description of all classes and methods will found in the documentation.
Check out other ours packages ๐ฆ!