@@ -69,11 +69,11 @@ object Settings:
69
69
70
70
def updateIn (state : SettingsState , x : Any ): SettingsState = x match
71
71
case _ : T => state.update(idx, x)
72
- case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${implicitly [ClassTag [T ]]}" )
72
+ case _ => throw IllegalArgumentException (s " found: $x of type ${x.getClass.getName}, required: ${summon [ClassTag [T ]]}" )
73
73
74
74
def isDefaultIn (state : SettingsState ): Boolean = valueIn(state) == default
75
75
76
- def isMultivalue : Boolean = implicitly [ClassTag [T ]] == ListTag
76
+ def isMultivalue : Boolean = summon [ClassTag [T ]] == ListTag
77
77
78
78
def legalChoices : String =
79
79
choices match {
@@ -106,6 +106,11 @@ object Settings:
106
106
def missingArg =
107
107
fail(s " missing argument for option $name" , args)
108
108
109
+ def setBoolean (argValue : String , args : List [String ]) =
110
+ if argValue.equalsIgnoreCase(" true" ) || argValue.isEmpty then update(true , args)
111
+ else if argValue.equalsIgnoreCase(" false" ) then update(false , args)
112
+ else fail(s " $argValue is not a valid choice for boolean setting $name" , args)
113
+
109
114
def setString (argValue : String , args : List [String ]) =
110
115
choices match
111
116
case Some (xs) if ! xs.contains(argValue) =>
@@ -126,9 +131,9 @@ object Settings:
126
131
catch case _ : NumberFormatException =>
127
132
fail(s " $argValue is not an integer argument for $name" , args)
128
133
129
- def doSet (argRest : String ) = ((implicitly [ClassTag [T ]], args): @ unchecked) match {
134
+ def doSet (argRest : String ) = ((summon [ClassTag [T ]], args): @ unchecked) match {
130
135
case (BooleanTag , _) =>
131
- update( true , args)
136
+ setBoolean(argRest , args)
132
137
case (OptionTag , _) =>
133
138
update(Some (propertyClass.get.getConstructor().newInstance()), args)
134
139
case (ListTag , _) =>
@@ -290,6 +295,6 @@ object Settings:
290
295
publish(Setting (name, descr, default))
291
296
292
297
def OptionSetting [T : ClassTag ](name : String , descr : String , aliases : List [String ] = Nil ): Setting [Option [T ]] =
293
- publish(Setting (name, descr, None , propertyClass = Some (implicitly [ClassTag [T ]].runtimeClass), aliases = aliases))
298
+ publish(Setting (name, descr, None , propertyClass = Some (summon [ClassTag [T ]].runtimeClass), aliases = aliases))
294
299
}
295
300
end Settings
0 commit comments