Skip to content

Commit

Permalink
Ignore case for boolean option values in protoc-gen-grpc-swift (#20)
Browse files Browse the repository at this point in the history
Motivation:

The protoc-gen-grpc-swift plugin has a few boolean options which
currently require a lowercased value. This is overly strict, the casing
of "true"/"false" shouldn't matter.

Modifications:

- Ignore case for boolean optioned values

Result:

Easier to use protoc-gen-grpc-swift
  • Loading branch information
glbrntt authored Dec 12, 2024
1 parent af08da4 commit 9b79693
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/protoc-gen-grpc-swift/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ struct GeneratorOptions {
}

case "Server":
if let value = Bool(pair.value) {
if let value = Bool(pair.value.lowercased()) {
self.generateServer = value
} else {
throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
}

case "Client":
if let value = Bool(pair.value) {
if let value = Bool(pair.value.lowercased()) {
self.generateClient = value
} else {
throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
Expand Down Expand Up @@ -142,14 +142,14 @@ struct GeneratorOptions {
}

case "ReflectionData":
if let value = Bool(pair.value) {
if let value = Bool(pair.value.lowercased()) {
self.generateReflectionData = value
} else {
throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
}

case "UseAccessLevelOnImports":
if let value = Bool(pair.value) {
if let value = Bool(pair.value.lowercased()) {
self.useAccessLevelOnImports = value
} else {
throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
Expand Down

0 comments on commit 9b79693

Please sign in to comment.