Remove outdated code

This commit is contained in:
Erik 2024-03-28 21:07:11 +02:00
parent b41c076181
commit 54423a9395
4 changed files with 18 additions and 19 deletions

View File

@ -73,7 +73,6 @@ class Parser extends EventEmitter
#globalFlags: CommandOption[];
#allowIncompleteReturn: string[];
constructor ({ commands, prefix, debug = false, resolver,
allowDefaultOnRequired, globalFlags = [], allowIncompleteReturn }: ParserOptions)
{

View File

@ -23,16 +23,7 @@ abstract class Command implements ICommand
this.aliases = def.aliases || [];
this.help = def.help;
// Add a built-in help flag to any non-subcommand option
this.options = [
new CommandOption({
name: 'help',
type: OptionType.BOOLEAN,
flag: true,
valueOptional: true,
defaultValue: true
})
];
this.options = [ ];
for (const opt of def.options || [])
{

View File

@ -39,14 +39,6 @@ class CommandOption implements ICommandOption
this.help = def.help;
this.options = [];
if (SUB.includes(this.type))
this.options.push(new CommandOption({
name: 'help',
type: OptionType.BOOLEAN,
flag: true,
valueOptional: true,
defaultValue: true
}));
for (const opt of def.options || [])
{

View File

@ -1,6 +1,20 @@
import { Parser, Command, OptionType } from '../build/esm/index.js';
const commands = [
new Command({
name: 'test',
options: [{
name: 'sub',
type: OptionType.SUB_COMMAND,
options: [{
name: 'flag',
type: OptionType.BOOLEAN,
defaultValue: true,
valueOptional: true,
flag: true
}]
}]
}),
new Command({
name: 'create',
options: [{
@ -52,6 +66,7 @@ const commands = [
})
];
const [first] = commands;
const parser = new Parser({
commands, prefix: '', debug: true,
globalFlags: [{
@ -67,6 +82,8 @@ parser.on('debug', console.log);
console.log((await parser.parseMessage('create code -a 1')));
console.log((await parser.parseMessage('create code --help')));
console.log(await parser.parseMessage('create --help'));
console.log((await parser.parseMessage('test sub --help')));
console.log(first.subcommand('sub').options);
console.log((await parser.parseMessage('create code')));