jbang
jbang copied to clipboard
Know JBang version in custom JBang scripts or commands
Is your feature request related to a problem? Please describe.
To know the jbang version at runtime in custom jbang app (eg camel-jbang)
Describe the solution you'd like A clear and concise description of what you want to happen.
I would like jbang to automatic set a JVM system property with the jbang version so I can find out without having to use any jbang API as I need this in a neutral way.
In my camel jbang commands then I only have dependency on picocli and therefore cannot use jbang JARs.
That's not a bad idea. 👍
Here is a sample what the Camel CLI we are working on
~/workspace ❯ camel get
PID NAME CAMEL PLATFORM READY STATE AGE TOTAL FAILED INFLIGHT SINCE-LAST
49448 bar.yaml 3.19.0-SNAPSHOT JBang 1/1 Started 6s 3 0 0 0s
In the PLATFORM column I would like to say
JBang v0.97.0
This would probably better to be environment variables rather than system properties to be consistent when using native built apps.
+1 on the feature.
This would probably better to be environment variables rather than system properties
True, but I don't think we can actually do that. Or at least not easily. Because of the way we run the final code. On Linux and Mac we could generate a command line like JBANG_VERSION=1.2.3 java ......
but that won't work on Windows. We'd need multi-line output which is notoriously hard to pull off, especially using CMD.
So it's probably easier to just generate an extra -Djbang.version=1.2.3
argument.
There is a version.txt
in the cache folder.
~/.jbang/cache/version.txt
This file has 0.106.1 on my laptop.
But I just upgraded to 0.106.3 via skdman
~/workspace ❯ cat ~/.jbang/cache/version.txt 0.106.1% ~/workspace ❯ jbang -V 0.106.3
Yes, that only gets updated once JBang checks for a new version (which you can force by running jbang version -- check
IIRC)