Skip to content

Commit

Permalink
Simplify PropertyValueSource.from overload implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Sep 26, 2023
1 parent 31a16b8 commit d661506
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,7 @@ object PropertiesValueSource {
requireValid: Boolean = false,
getKey: (Context, Option) -> String = ValueSource.getKey(joinSubcommands = "."),
): ValueSource {
val properties = Properties()
if (file.isFile) {
try {
file.bufferedReader().use { properties.load(it) }
} catch (e: Throwable) {
if (requireValid) throw InvalidFileFormat(
file.name,
e.message ?: "could not read file"
)
}
}

return from(properties, getKey)
return from(file.toPath(), requireValid, getKey)
}

/**
Expand Down

0 comments on commit d661506

Please sign in to comment.