Pkl ignores format when evaluating expressions #233

Closed
opened 2025-12-30 01:22:33 +01:00 by adam · 2 comments
Owner

Originally created by @pauloborges on GitHub (Oct 26, 2024).

Example file:

cat file.pkl
field {
    key = "value"
}

Evaluating the whole file works as expected:

pkl eval -f yaml file.pkl
field:
  key: value

But evaluating an expression ignores the format argument:

pkl eval -f yaml -x field file.pkl
new Dynamic { key = "value" }
Originally created by @pauloborges on GitHub (Oct 26, 2024). Example file: ``` cat file.pkl field { key = "value" } ``` Evaluating the whole file works as expected: ``` pkl eval -f yaml file.pkl field: key: value ``` But evaluating an expression ignores the format argument: ``` pkl eval -f yaml -x field file.pkl new Dynamic { key = "value" } ```
adam closed this issue 2025-12-30 01:22:33 +01:00
Author
Owner

@HT154 commented on GitHub (Oct 27, 2024):

This is currently expected behavior and not a bug, but this is definitely a valid feature request. You can emulate the desired behavior using -x 'output.renderer.renderValue(<expr>).

You can see how the output format selection is implemented here, which might help explain what's happening here: 466ae6fd4c/stdlib/base.pkl (L93-L107)

@HT154 commented on GitHub (Oct 27, 2024): This is currently expected behavior and not a bug, but this is definitely a valid feature request. You can emulate the desired behavior using `-x 'output.renderer.renderValue(<expr>)`. You can see how the output format selection is implemented here, which might help explain what's happening here: https://github.com/apple/pkl/blob/466ae6fd4c72aa7ccabde970131eccbc2a690b12/stdlib/base.pkl#L93-L107
Author
Owner

@ThinkChaos commented on GitHub (Jan 17, 2025):

The workaround above doesn't work, it should be -x 'module.output.renderer.renderValue(<expr>)

@ThinkChaos commented on GitHub (Jan 17, 2025): The workaround above doesn't work, it should be `-x 'module.output.renderer.renderValue(<expr>)`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#233