Originally created by @lilyball on GitHub (May 17, 2024).
The --output-path flag supports placeholders for generating the output filename from inputs. Unfortunately there is no placeholder that will provide the file extension. %{outputFormat} exists but it corresponds to the --format flag rather than the actual ValueRenderer subclass used, and it's the name of the format rather than the extension (which is the same for some formats, but not for others).
I'd like to see two things. First, a new placeholder %{outputExtension} that evaluates to if (output.renderer.extension != null) ".\(output.renderer.extension)" else "". The inclusion of the leading period here is because ValueRenderer.extension is optional. This way I can write something like pkl eval -o 'config%{outputExtension}' config.pkl and get the appropriate extension no matter how it's rendering. The second is a shorthand for %{moduleName}%{outputExtension}. This could be another placeholder, but for ease of use I'd prefer a separate flag -O, --output-dir that takes a directory (supporting placeholders). So with this, -O dir would be equivalent to saying -o dir/%{moduleName}%{outputExtension}.
Given that the Pkl Style Guide recommends that Pkl files representing static config files be named to match the target filename, this means the -O flag would be the simplest way to render static config files.
Originally created by @lilyball on GitHub (May 17, 2024).
The [`--output-path` flag](https://pkl-lang.org/main/current/pkl-cli/index.html#output-path) supports placeholders for generating the output filename from inputs. Unfortunately there is no placeholder that will provide the file extension. `%{outputFormat}` exists but it corresponds to the `--format` flag rather than the actual `ValueRenderer` subclass used, and it's the name of the format rather than the extension (which is the same for some formats, but not for others).
I'd like to see two things. First, a new placeholder `%{outputExtension}` that evaluates to `if (output.renderer.extension != null) ".\(output.renderer.extension)" else ""`. The inclusion of the leading period here is because `ValueRenderer.extension` is optional. This way I can write something like `pkl eval -o 'config%{outputExtension}' config.pkl` and get the appropriate extension no matter how it's rendering. The second is a shorthand for `%{moduleName}%{outputExtension}`. This could be another placeholder, but for ease of use I'd prefer a separate flag `-O, --output-dir` that takes a directory (supporting placeholders). So with this, `-O dir` would be equivalent to saying `-o dir/%{moduleName}%{outputExtension}`.
Given that the [Pkl Style Guide](https://pkl-lang.org/main/current/style-guide/index.html#filename) recommends that Pkl files representing static config files be named to match the target filename, this means the `-O` flag would be the simplest way to render static config files.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @lilyball on GitHub (May 17, 2024).
The
--output-pathflag supports placeholders for generating the output filename from inputs. Unfortunately there is no placeholder that will provide the file extension.%{outputFormat}exists but it corresponds to the--formatflag rather than the actualValueRenderersubclass used, and it's the name of the format rather than the extension (which is the same for some formats, but not for others).I'd like to see two things. First, a new placeholder
%{outputExtension}that evaluates toif (output.renderer.extension != null) ".\(output.renderer.extension)" else "". The inclusion of the leading period here is becauseValueRenderer.extensionis optional. This way I can write something likepkl eval -o 'config%{outputExtension}' config.pkland get the appropriate extension no matter how it's rendering. The second is a shorthand for%{moduleName}%{outputExtension}. This could be another placeholder, but for ease of use I'd prefer a separate flag-O, --output-dirthat takes a directory (supporting placeholders). So with this,-O dirwould be equivalent to saying-o dir/%{moduleName}%{outputExtension}.Given that the Pkl Style Guide recommends that Pkl files representing static config files be named to match the target filename, this means the
-Oflag would be the simplest way to render static config files.