@@ -107,7 +107,7 @@ fileprivate extension CommandInfoV0 {
107
107
let arguments = commandStack
108
108
. allArguments ( )
109
109
. mergingCompositeArguments ( )
110
- . map ( ArgumentInfoV0 . init)
110
+ . compactMap ( ArgumentInfoV0 . init)
111
111
112
112
self = CommandInfoV0 (
113
113
superCommands: superCommands,
@@ -121,9 +121,10 @@ fileprivate extension CommandInfoV0 {
121
121
}
122
122
123
123
fileprivate extension ArgumentInfoV0 {
124
- init ( argument: ArgumentDefinition ) {
124
+ init ? ( argument: ArgumentDefinition ) {
125
+ guard let kind = ArgumentInfoV0 . KindV0 ( argument: argument) else { return nil }
125
126
self . init (
126
- kind: ArgumentInfoV0 . KindV0 ( argument : argument ) ,
127
+ kind: kind ,
127
128
shouldDisplay: argument. help. shouldDisplay,
128
129
isOptional: argument. help. options. contains ( . isOptional) ,
129
130
isRepeating: argument. help. options. contains ( . isRepeating) ,
@@ -138,7 +139,7 @@ fileprivate extension ArgumentInfoV0 {
138
139
}
139
140
140
141
fileprivate extension ArgumentInfoV0 . KindV0 {
141
- init ( argument: ArgumentDefinition ) {
142
+ init ? ( argument: ArgumentDefinition ) {
142
143
switch argument. kind {
143
144
case . named:
144
145
switch argument. update {
@@ -150,7 +151,7 @@ fileprivate extension ArgumentInfoV0.KindV0 {
150
151
case . positional:
151
152
self = . positional
152
153
case . default:
153
- preconditionFailure ( " argument.kind must not be .default " )
154
+ return nil
154
155
}
155
156
}
156
157
}
0 commit comments