command-parser/tests/playground.js
Navy.gif c669d60428
All checks were successful
continuous-integration/drone/push Build is passing
default help option to commands and subcommands
bugfix for boolean type parse
2023-05-05 17:32:29 +03:00

21 lines
658 B
JavaScript

import { Parser, Command, OptionType } from '../build/esm/index.js';
const command = new Command({
name: 'create',
options: [{
name: 'registration-code',
aliases: ['code'],
type: OptionType.SUB_COMMAND,
options: [{
name: 'amount',
flag: true,
type: OptionType.INTEGER,
defaultValue: 1,
valueOptional: true
}]
}]
});
const parser = new Parser({ commands: [command], prefix: '', debug: true });
parser.on('debug', console.log)
console.log(await parser.parseMessage('create code -a 1'));
console.log(await parser.parseMessage('create code --help'))