v6.0.4
๐ฆ 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.createHelpOptions(),
'myString': {
shortName: 's',
description: 'This is a string flag.',
convertor: Arguments.stringConvertor,
},
'myNumber': {
shortName: 'n',
description: 'This is a number flag.',
convertor: Arguments.numberConvertor,
default: () => 0
},
'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} โ ๐ญ`;
},
},
'myDeprecated': {
convertor: Arguments.stringConvertor,
excludeFromHelp: true
},
})
.setDescription("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 ๐ฆ!