jbang
jbang copied to clipboard
jbang bootstrap file.java
its a bit verbose so probably not worth adding on everything but if one do this:
//usr/bin/env echo '
/**** BOOTSTRAP jbang ****\'>/dev/null
command -v jbang >/dev/null 2>&1 || curl -Ls https://sh.jbang.dev | bash -s app setup
exec jbang "$0" "$@" ; exit $?
\*** IMPORTANT: Any code including imports and annotations must come after this line ***/
the script will be self-bootstrapping even when no jbang installed.
should we add a jbang bootstrap file.java which will add that as the first line? (replacing ///usr/bin/env jbang "$0" "$@" ; exit $? if present?
instead of "polluting" jbang I went ahead and made this:
jbang bootstrap@jbangdev yourscript.java
that will modify yourscript.java in place and add/replace the traditional /// header with the bootstrapping code.
This is where the plugin system I created some time ago could help. In its simplest form you could just create an alias for it named jbang-bootstrap and it would automatically be available as jbang bootstrap. A user can then decide for themselves if they use it often enough to install it as a plugin or if they are okay with running jbang bootstrap@jbangdev ... each time.