Skip to content

Commit

Permalink
Patch ArgParser to correctly throw BadArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Dec 30, 2019
1 parent 753e93b commit bd60589
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply plugin: 'kotlin'
apply plugin: 'com.github.johnrengelman.shadow'

group 'me.devoxin'
version '1.5.0'
version '1.5.1'
sourceCompatibility = 1.8

repositories {
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/me/devoxin/flight/arguments/ArgParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,14 @@ class ArgParser(
}
}

if (!result.isPresent && !arg.isNullable) {
if (!result.isPresent && !arg.isNullable && (!arg.optional || argument.isNotEmpty())) {
throw BadArgument(arg, argument)
}

return result.orElse(null)
}

companion object {
private val logger = LoggerFactory.getLogger(ArgParser::class.java)
val parsers = hashMapOf<Class<*>, Parser<*>>()

fun parseArguments(cmd: CommandWrapper, ctx: Context, args: List<String>): HashMap<KParameter, Any?> {
Expand Down

0 comments on commit bd60589

Please sign in to comment.