File tree Expand file tree Collapse file tree 6 files changed +9
-4
lines changed
src/commonMain/kotlin/com/github/ajalt/clikt
test/src/commonTest/kotlin/com/github/ajalt/clikt/parameters/types Expand file tree Collapse file tree 6 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -708,6 +708,7 @@ public abstract interface class com/github/ajalt/clikt/output/Localization {
708708 public abstract fun requiredMutexOption (Ljava/lang/String;)Ljava/lang/String;
709709 public abstract fun stringMetavar ()Ljava/lang/String;
710710 public abstract fun switchOptionEnvvar ()Ljava/lang/String;
711+ public abstract fun uintConversionError (Ljava/lang/String;)Ljava/lang/String;
711712 public abstract fun unclosedQuote ()Ljava/lang/String;
712713 public abstract fun usageError ()Ljava/lang/String;
713714 public abstract fun usageTitle ()Ljava/lang/String;
@@ -768,6 +769,7 @@ public final class com/github/ajalt/clikt/output/Localization$DefaultImpls {
768769 public static fun requiredMutexOption (Lcom/github/ajalt/clikt/output/Localization;Ljava/lang/String;)Ljava/lang/String;
769770 public static fun stringMetavar (Lcom/github/ajalt/clikt/output/Localization;)Ljava/lang/String;
770771 public static fun switchOptionEnvvar (Lcom/github/ajalt/clikt/output/Localization;)Ljava/lang/String;
772+ public static fun uintConversionError (Lcom/github/ajalt/clikt/output/Localization;Ljava/lang/String;)Ljava/lang/String;
771773 public static fun unclosedQuote (Lcom/github/ajalt/clikt/output/Localization;)Ljava/lang/String;
772774 public static fun usageError (Lcom/github/ajalt/clikt/output/Localization;)Ljava/lang/String;
773775 public static fun usageTitle (Lcom/github/ajalt/clikt/output/Localization;)Ljava/lang/String;
Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ interface Localization {
137137 /* * Invalid value for a parameter of type [Int] or [Long] */
138138 fun intConversionError (value : String ) = " $value is not a valid integer"
139139
140+ /* * Invalid value for a parameter of type [UInt] or [ULong] */
141+ fun uintConversionError (value : String ) = " $value is not a valid unsigned integer"
142+
140143 /* * Invalid value for a parameter of type [Boolean] */
141144 fun boolConversionError (value : String ) = " $value is not a valid boolean"
142145
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import com.github.ajalt.clikt.parameters.transform.TransformContext
1010
1111
1212private val conversion: TransformContext .(String ) -> UInt =
13- { it.toUIntOrNull() ? : fail(context.localization.intConversionError (it)) }
13+ { it.toUIntOrNull() ? : fail(context.localization.uintConversionError (it)) }
1414
1515/* * Convert the argument values to an `UInt` */
1616fun RawArgument.uint (): ProcessedArgument <UInt , UInt > = convert(conversion = conversion)
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import com.github.ajalt.clikt.parameters.transform.TransformContext
1010
1111
1212private val conversion: TransformContext .(String ) -> ULong =
13- { it.toULongOrNull() ? : fail(context.localization.intConversionError (it)) }
13+ { it.toULongOrNull() ? : fail(context.localization.uintConversionError (it)) }
1414
1515/* * Convert the argument values to a `ULong` */
1616fun RawArgument.ulong (): ProcessedArgument <ULong , ULong > = convert(conversion = conversion)
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class UIntTest {
5555 }
5656
5757 shouldThrow<BadParameterValue > { C ().parse(" --foo bar" ) }
58- .formattedMessage shouldBe " invalid value for --foo: bar is not a valid integer"
58+ .formattedMessage shouldBe " invalid value for --foo: bar is not a valid unsigned integer"
5959
6060 shouldThrow<NoSuchOption > { C ().parse(" -2" ) }
6161 shouldThrow<BadParameterValue > { C ().parse(" --foo=-1" ) }
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ class ULongTest {
4040 }
4141
4242 shouldThrow<BadParameterValue > { C ().parse(" --foo bar" ) }
43- .formattedMessage shouldBe " invalid value for --foo: bar is not a valid integer"
43+ .formattedMessage shouldBe " invalid value for --foo: bar is not a valid unsigned integer"
4444
4545 shouldThrow<NoSuchOption > { C ().parse(" -2" ) }
4646 shouldThrow<BadParameterValue > { C ().parse(" --foo=-1" ) }
You can’t perform that action at this time.
0 commit comments