Skip to content

Commit 69eea78

Browse files
committed
send NotFound when positional absent. Ensure there is child before checking its specification
1 parent f6ea940 commit 69eea78

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Clap-Core/ClapCompositeMatch.class.st

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ClapCompositeMatch >> at: identifierOrSpec [
2323
ifAbsent: [
2424
specification at: identifierOrSpec
2525
ifPresent: [ :spec | ClapImplicit of: spec in: self ]
26-
ifAbsent: [ self notYetImplemented ] ]
26+
ifAbsent: [ NotFound signal: 'Cannot find ' , identifierOrSpec asSymbol, '!' ] ]
2727
]
2828

2929
{ #category : #'accessing - children' }
@@ -71,6 +71,12 @@ ClapCompositeMatch >> flags [
7171
^ children select: [ :each | specification flags includes: each specification ]
7272
]
7373

74+
{ #category : #testing }
75+
ClapCompositeMatch >> hasChild [
76+
77+
^ children isNotEmpty
78+
]
79+
7480
{ #category : #testing }
7581
ClapCompositeMatch >> includesMatchOf: identifierOrSpec [
7682
^ children anySatisfy: [ :arg | arg isMatchOf: identifierOrSpec ]

src/Clap-Core/ClapContext.class.st

+8-1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ ClapContext >> hasFlag: anIdentifier [
232232
^ (self lastSubcommand occurrencesOf: anIdentifier) isNotEmpty
233233
]
234234

235+
{ #category : #private }
236+
ClapContext >> hasPositional: aFlagMatch [
237+
238+
^ aFlagMatch hasChild
239+
and: [ aFlagMatch child specification isPositional ]
240+
]
241+
235242
{ #category : #activation }
236243
ClapContext >> hasSessionChanged [
237244
^ session ~~ Smalltalk session
@@ -287,7 +294,7 @@ ClapContext >> positional: anIdentifier [
287294
identifierMatches := (self lastSubcommand occurrencesOf: anIdentifier)
288295
select: [ :identifierMatch |
289296
identifierMatch specification isPositional
290-
or: [ identifierMatch specification isFlag and: [ identifierMatch child specification isPositional ] ] ].
297+
or: [ identifierMatch specification isFlag and: [ self hasPositional: identifierMatch ] ] ].
291298
^ identifierMatches
292299
ifEmpty: [ NotFound signal: 'No positional found with id: ', anIdentifier ]
293300
]

0 commit comments

Comments
 (0)