@vexify-org/yaggs
v8.1.1
Published
A powerful CLI argument parser, better than yargs. Features: Deprecation Warnings, Subcommand Aliases, Extended Type Validators, Default Value Merge, Conflict Detection, Exclusive Groups, Interactive Prompts
Readme
@vexify-org/yaggs
A powerful CLI argument parser for Node.js, designed as a modern alternative to yargs.
Features
- Deprecation warnings for deprecated options
- Subcommand aliases
- Extended type validators (email, URL, UUID, etc.)
- Default value merge
- Conflict detection
- Exclusive groups
- Interactive prompts
- Zero dependencies
Installation
npm install @vexify-org/yaggsUsage
Basic Example
const yaggs = require('@vexify-org/yaggs');
const argv = yaggs
.option('name', {
alias: 'n',
type: 'string',
description: 'Your name',
default: 'World'
})
.option('count', {
alias: 'c',
type: 'number',
description: 'Number of times to greet',
default: 1
})
.argv;
console.log(`Hello, ${argv.name}!`.repeat(argv.count));Commands
yaggs
.command('start', 'Start MineP2P client', (y) => {
y.option('room', {
type: 'string',
description: 'Room ID to join'
});
}, (argv) => {
console.log('Starting...', argv.room);
})
.command('stop', 'Stop MineP2P client', null, () => {
console.log('Stopping...');
})
.argv;Note: use simple command names (
start, notstart [room]) and bind room-style inputs as options. To register a bare handler with no sub-command builder, passnullas the third argument (the builder) and your handler as the fourth.
Type Validators
yaggs
.option('email', {
type: 'email',
description: 'Email address'
})
.option('url', {
type: 'url',
description: 'Website URL'
})
.option('uuid', {
type: 'uuid',
description: 'UUID'
})
.argv;Deprecation Warnings
yaggs
.option('old-flag', {
type: 'boolean',
deprecated: true,
deprecatedMessage: 'Use --new-flag instead'
})
.argv;Exclusive Groups
yaggs
.option('json', {
type: 'boolean',
conflicts: 'yaml'
})
.option('yaml', {
type: 'boolean',
conflicts: 'json'
})
.argv;API
yaggs.option(name, options)- Define an optionyaggs.command(cmd, desc, builder, handler)- Define a commandyaggs.parse(args)- Parse argumentsyaggs.argv- Get parsed arguments
Changelog
8.1.1 — bug fixes
exitProcess: falseis now honoured. Passing it as a constructor option (or via.exitProcess(false)) stops--help/--versionfrom callingprocess.exit, so yaggs no longer kills the host when you embed it.- Validation errors are non-fatal.
_handleErrorno longer callsprocess.exit(1). Usage / validation failures are echoed to stderr and collected intoresult.error/result.errorsfor the caller to inspect. - Middleware now runs exactly once in
parseAsync()/run()(previously it ran twice). - Negative numbers and flag-like strings work as option values
(e.g.
--count -5,--msg --weird), while a following known flag still terminates the previous option. envmethod unified.yaggs.env('KEY', 'value')sets a process env var,yaggs.env('KEY')reads one, andyaggs.env('<option>', '<VAR>')binds an option to an env var — the two overlapping definitions are now one.- Environment fallback now applies when an option is absent and overrides config (CLI > env > config > defaults).
- Option names preserve case (
apiKeystaysresult.apiKey). demandCommand()is now enforced anddefaultHandler(fn)is a real method instead of a dead property.impliesoverrides a default value but never an explicit CLI value.- Added
.argvgetter soyaggs.option(...).argvworks as documented.
Compatibility
- Node.js >= 14.0.0
- Drop-in replacement for yargs in most cases
License
Apache-2.0 - Copyright (c) Vexify 2026
