Multi-file output should honor the output format flag #140

Open
opened 2025-12-30 01:21:25 +01:00 by adam · 2 comments
Owner

Originally created by @netvl on GitHub (Apr 10, 2024).

Currently, evaluation of a Pkl module with multi-file output ignores the output format parameter for the pkl eval call (or the outputFormat property in case of the Gradle plugin). For example (snippet taken from the docs):

// birds.pkl

pigeon {
  name = "Pigeon"
  diet = "Seeds"
}
parrot {
  name = "Parrot"
  diet = "Seeds"
}
output {
  files {
    ["birds/pigeon.out"] {
      value = pigeon
    }
    ["birds/parrot.out"] {
      value = parrot
    }
  }
}
> pkl eval -m output/ -f yaml birds.pkl
output/birds/pigeon.out
output/birds/parrot.out
> cat output/birds/parrot.out
name = "Parrot"
diet = "Seeds"
> cat output/birds/pigeon.out
name = "Pigeon"
diet = "Seeds"

This is different from the regular single-file output mode, where -f would determine the default renderer in case it is not explicitly specified.

It would probably make sense for the -f argument to be honored for multi-file output as well, in the same way as for single-file output - by determining the output format in case an explicit renderer is not defined.

Originally created by @netvl on GitHub (Apr 10, 2024). Currently, evaluation of a Pkl module with multi-file output ignores the output format parameter for the `pkl eval` call (or the `outputFormat` property in case of the Gradle plugin). For example (snippet taken from the [docs](https://pkl-lang.org/main/current/language-reference/index.html#multiple-file-output)): ```pkl // birds.pkl pigeon { name = "Pigeon" diet = "Seeds" } parrot { name = "Parrot" diet = "Seeds" } output { files { ["birds/pigeon.out"] { value = pigeon } ["birds/parrot.out"] { value = parrot } } } ``` ``` > pkl eval -m output/ -f yaml birds.pkl output/birds/pigeon.out output/birds/parrot.out > cat output/birds/parrot.out name = "Parrot" diet = "Seeds" > cat output/birds/pigeon.out name = "Pigeon" diet = "Seeds" ``` This is different from the regular single-file output mode, where `-f` would determine the default renderer in case it is not explicitly specified. It would probably make sense for the `-f` argument to be honored for multi-file output as well, in the same way as for single-file output - by determining the output format in case an explicit renderer is not defined.
Author
Owner

@bioball commented on GitHub (Apr 11, 2024):

Makes sense.

This would be a breaking change, but the breakage would be: -f previously didn't affect output, and now does.

@bioball commented on GitHub (Apr 11, 2024): Makes sense. This would be a breaking change, but the breakage would be: `-f` previously didn't affect output, and now does.
Author
Owner

@StefMa commented on GitHub (Apr 11, 2024):

Is this a bug than a feature?
If I look into the CliEvaluator I see that it set the expected format:

https://github.com/apple/pkl/blob/main/pkl-cli%2Fsrc%2Fmain%2Fkotlin%2Forg%2Fpkl%2Fcli%2FCliEvaluator.kt#L199-L203

But it seems it will not be respected 🤔

@StefMa commented on GitHub (Apr 11, 2024): Is this a bug than a feature? If I look into the CliEvaluator I see that it set the expected format: https://github.com/apple/pkl/blob/main/pkl-cli%2Fsrc%2Fmain%2Fkotlin%2Forg%2Fpkl%2Fcli%2FCliEvaluator.kt#L199-L203 But it seems it will not be respected 🤔
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#140