diff --git a/codegen-sbt/src/main/scala/caliban/codegen/CalibanSettings.scala b/codegen-sbt/src/main/scala/caliban/codegen/CalibanSettings.scala index 95653e181..18288ea43 100644 --- a/codegen-sbt/src/main/scala/caliban/codegen/CalibanSettings.scala +++ b/codegen-sbt/src/main/scala/caliban/codegen/CalibanSettings.scala @@ -28,6 +28,7 @@ sealed trait CalibanSettings { final def preserveInputNames(value: Boolean): Self = withSettings(_.preserveInputNames(value)) final def addDerives(value: Boolean): Self = withSettings(_.addDerives(value)) final def envForDerives(value: String): Self = withSettings(_.envForDerives(value)) + final def excludeDeprecated(value: Boolean): Self = withSettings(_.excludeDeprecated(value)) } final case class CalibanFileSettings(file: File, settings: CalibanCommonSettings) extends CalibanSettings { diff --git a/codegen-sbt/src/main/scala/caliban/codegen/OptionsParser.scala b/codegen-sbt/src/main/scala/caliban/codegen/OptionsParser.scala index 61b1b7f4e..db80b5aa7 100644 --- a/codegen-sbt/src/main/scala/caliban/codegen/OptionsParser.scala +++ b/codegen-sbt/src/main/scala/caliban/codegen/OptionsParser.scala @@ -22,7 +22,8 @@ object OptionsParser { preserveInputNames: Option[Boolean], supportIsRepeatable: Option[Boolean], addDerives: Option[Boolean], - envForDerives: Option[String] + envForDerives: Option[String], + excludeDeprecated: Option[Boolean] ) private object DescriptorUtils { @@ -74,7 +75,8 @@ object OptionsParser { rawOpts.preserveInputNames, rawOpts.supportIsRepeatable, rawOpts.addDerives, - rawOpts.envForDerives + rawOpts.envForDerives, + rawOpts.excludeDeprecated ) }.option case _ => ZIO.none diff --git a/codegen-sbt/src/test/scala/caliban/codegen/OptionsParserSpec.scala b/codegen-sbt/src/test/scala/caliban/codegen/OptionsParserSpec.scala index 40a164a9a..eb09dce6c 100644 --- a/codegen-sbt/src/test/scala/caliban/codegen/OptionsParserSpec.scala +++ b/codegen-sbt/src/test/scala/caliban/codegen/OptionsParserSpec.scala @@ -30,6 +30,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -59,6 +60,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -89,6 +91,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -137,6 +140,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -167,6 +171,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -197,6 +202,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -227,6 +233,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -257,6 +264,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -287,6 +295,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -317,6 +326,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -347,6 +357,7 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) @@ -377,6 +388,7 @@ object OptionsParserSpec extends ZIOSpecDefault { Some(true), None, None, + None, None ) ) @@ -407,11 +419,43 @@ object OptionsParserSpec extends ZIOSpecDefault { None, None, None, + None, None ) ) ) } + }, + test("provide excludeDeprecated") { + val input = List("schema", "output", "--excludeDeprecated", "true") + OptionsParser.fromArgs(input).map { result => + assertTrue( + result == + Some( + Options( + "schema", + "output", + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + None, + Some(true) + ) + ) + ) + } } ) }