@@ -62,6 +62,7 @@ object Settings:
62
62
prefix : String = " " ,
63
63
aliases : List [String ] = Nil ,
64
64
depends : List [(Setting [? ], Any )] = Nil ,
65
+ ignoreInvalidArgs : Boolean = false ,
65
66
propertyClass : Option [Class [? ]] = None )(private [Settings ] val idx : Int ) {
66
67
67
68
private var changed : Boolean = false
@@ -104,8 +105,16 @@ object Settings:
104
105
def fail (msg : String , args : List [String ]) =
105
106
ArgsSummary (sstate, args, errors :+ msg, warnings)
106
107
108
+ def warn (msg : String , args : List [String ]) =
109
+ ArgsSummary (sstate, args, errors, warnings :+ msg)
110
+
107
111
def missingArg =
108
- fail(s " missing argument for option $name" , args)
112
+ val msg = s " missing argument for option $name"
113
+ if ignoreInvalidArgs then warn(msg + " , the tag was ignored" , args) else fail(msg, args)
114
+
115
+ def invalidChoices (invalid : List [String ]) =
116
+ val msg = s " invalid choice(s) for $name: ${invalid.mkString(" ," )}"
117
+ if ignoreInvalidArgs then warn(msg + " , the tag was ignored" , args) else fail(msg, args)
109
118
110
119
def setBoolean (argValue : String , args : List [String ]) =
111
120
if argValue.equalsIgnoreCase(" true" ) || argValue.isEmpty then update(true , args)
@@ -144,7 +153,7 @@ object Settings:
144
153
choices match
145
154
case Some (valid) => strings.filterNot(valid.contains) match
146
155
case Nil => update(strings, args)
147
- case invalid => fail( s " invalid choice(s) for $name : ${invalid.mkString( " , " )} " , args )
156
+ case invalid => invalidChoices( invalid)
148
157
case _ => update(strings, args)
149
158
case (StringTag , _) if argRest.nonEmpty || choices.exists(_.contains(" " )) =>
150
159
setString(argRest, args)
@@ -287,6 +296,9 @@ object Settings:
287
296
def MultiChoiceHelpSetting (name : String , helpArg : String , descr : String , choices : List [ChoiceWithHelp [String ]], default : List [ChoiceWithHelp [String ]], aliases : List [String ] = Nil ): Setting [List [ChoiceWithHelp [String ]]] =
288
297
publish(Setting (name, descr, default, helpArg, Some (choices), aliases = aliases))
289
298
299
+ def UncompleteMultiChoiceHelpSetting (name : String , helpArg : String , descr : String , choices : List [ChoiceWithHelp [String ]], default : List [ChoiceWithHelp [String ]], aliases : List [String ] = Nil ): Setting [List [ChoiceWithHelp [String ]]] =
300
+ publish(Setting (name, descr, default, helpArg, Some (choices), aliases = aliases, ignoreInvalidArgs = true ))
301
+
290
302
def IntSetting (name : String , descr : String , default : Int , aliases : List [String ] = Nil ): Setting [Int ] =
291
303
publish(Setting (name, descr, default, aliases = aliases))
292
304
0 commit comments