A convention based argument parsing and formatting library, with strict validation checks
npm install @jil/args> A convention based argument parsing and formatting library, with strict validation checks. It _is not_ a command line
> interface.
``ts
import {parse} from '@jil/args';
interface Options {
help: boolean;
logLevel: 'info' | 'error' | 'warn';
version: boolean;
}
const {command, errors, options, params, rest} = parse
commands: ['build', 'install', 'update'],
options: {
help: {
default: false,
description: 'Show a help menu',
type: 'boolean',
short: 'H',
},
logLevel: {
choices: ['info', 'error', 'warn'],
default: 'info',
description: 'Customize logging level',
},
version: {
default: false,
description: 'Show the version number',
type: 'boolean',
short: 'V',
},
},
});
`
- Commands and sub-commands: cmd, cmd:sub--foo value
- Options (long and short) that set a value(s): , --foo=value, -f value, -f=value--bar
- Camel (preferred) or kebab cased option names.
- Flags (boolean options) that take no value: , -B--no-bar
- With implicit negation support: foo bar baz
- Parameters that act as standalone values: --
- Can be marked as required.
- Rest arguments that are passed to subsequent scripts (aggregated after ): foo -- barstring
- Supports , number, boolean, and list based values, with the addition of:-fBp
- Single value based on a list of possible choices.
- Multiple values with optional arity count requirements.
- Group multiple short options under a single argument:
- Increment a counter each time a short option is found in a group.
- Strict parser and validation checks, allowing for informative interfaces.
- Custom option and param validation for increased accuracy.
```
npm i @jil/args
- https://boostlib.dev/docs/args
- https://boostlib.dev/api/args