Skip to content

Commit

Permalink
fix: default subcommand argument behavior (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSegal855 committed Oct 8, 2022
1 parent a2bbd33 commit 6cef7c6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/subcommands/src/lib/Subcommand.ts
Expand Up @@ -128,7 +128,7 @@ export class Subcommand<PreParseReturn extends Args = Args, O extends Subcommand
mapping.type ??= 'method';

if (mapping.type === 'method') {
if (mapping.default) {
if (mapping.default && !defaultCommand) {
matchedWithGroupedSubcommand = false;
defaultCommand = mapping;
}
Expand Down Expand Up @@ -184,11 +184,7 @@ export class Subcommand<PreParseReturn extends Args = Args, O extends Subcommand

// No subcommand matched, let's try to run default, if any:
if (defaultCommand) {
if (subcommandOrGroup.isSome()) {
args.next();
}

// If we matched with a subcommand in a group we need to skip 1 more arg
// If we matched with a subcommand in a group we need to skip 1 the group name
if (matchedWithGroupedSubcommand) {
args.next();
}
Expand Down

0 comments on commit 6cef7c6

Please sign in to comment.