Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output path placeholders don't expose ValueRenderer.extension #501

Open
lilyball opened this issue May 17, 2024 · 0 comments
Open

Output path placeholders don't expose ValueRenderer.extension #501

lilyball opened this issue May 17, 2024 · 0 comments

Comments

@lilyball
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant