Skip to content

How to evaluate an expression in the CLI #707

Answered by HT154
translatenix asked this question in Q&A
Discussion options

You must be logged in to vote

You're right that there's no way to just evaluate an expression in isolation (similar to jq -n). I found myself running pkl eval -x '...' /dev/null on occasion when I needed that so I ended up defining a shell alias:

$ alias pklx='pkl eval /dev/null -x'
$ pklx '1 + 2'
3

There's some discussion and example for -x here: https://pkl-lang.org/main/current/pkl-cli/index.html#options

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@StefMa
Comment options

@HT154
Comment options

@translatenix
Comment options

@bioball
Comment options

@bioball
Comment options

Answer selected by translatenix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants