command-parser/tests/playground.js

22 lines
716 B
JavaScript
Raw Normal View History

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'));
2023-05-05 17:29:54 +02:00
console.log(await parser.parseMessage('create code --help'));
console.log(await parser.parseMessage('create --help'));