diff --git a/src/main/scala/io/viash/platforms/nextflow/NextflowAuto.scala b/src/main/scala/io/viash/platforms/nextflow/NextflowAuto.scala index 3d1145bdd..cdcbb9ebb 100644 --- a/src/main/scala/io/viash/platforms/nextflow/NextflowAuto.scala +++ b/src/main/scala/io/viash/platforms/nextflow/NextflowAuto.scala @@ -55,12 +55,8 @@ case class NextflowAuto( |Default: `false`. |""".stripMargin) @default("False") - publish: Either[Boolean, String] = Left(false) + publish: Either[Boolean, String] = Right("false") ) { - // if publish is a string, it must be "state" - val checkPublish = publish match { - case Left(value) => true - case Right(value) => value == "state" - } - assert(checkPublish, message = "publish must be either a boolean or equal to \"state\"") + assert(publish.isRight, message = "expected publish to be converted to a string") + assert(Seq("true", "false", "state").contains(publish.toOption.get), message = "publish must be either a boolean or equal to \"state\"") } \ No newline at end of file diff --git a/src/main/scala/io/viash/platforms/nextflow/package.scala b/src/main/scala/io/viash/platforms/nextflow/package.scala index fca12c85f..ddadbb656 100644 --- a/src/main/scala/io/viash/platforms/nextflow/package.scala +++ b/src/main/scala/io/viash/platforms/nextflow/package.scala @@ -28,7 +28,22 @@ package object nextflow { implicit val decodeNextflowDirectives: Decoder[NextflowDirectives] = deriveConfiguredDecoderFullChecks implicit val encodeNextflowAuto: Encoder.AsObject[NextflowAuto] = deriveConfiguredEncoder - implicit val decodeNextflowAuto: Decoder[NextflowAuto] = deriveConfiguredDecoderFullChecks + implicit val decodeNextflowAuto: Decoder[NextflowAuto] = deriveConfiguredDecoderFullChecks[NextflowAuto].prepare( + _.withFocus(_.mapObject{ conf => + val publish = conf.apply("publish").map { + publish => + publish.asBoolean match { + case Some(true) => Json.fromString("true") + case Some(false) => Json.fromString("false") + case None => publish + } + } + publish match { + case Some(publish) => conf.add("publish", publish) + case None => conf + } + }) + ) implicit val encodeNextflowConfig: Encoder.AsObject[NextflowConfig] = deriveConfiguredEncoder implicit val decodeNextflowConfig: Decoder[NextflowConfig] = deriveConfiguredDecoderFullChecks