jbang
jbang copied to clipboard
Generic remote-file argument support for `run`
It was a bit hard to come up with a good title, but I was basically thinking about something like this:
Imagine that you have a script that reads a local file:
jbang run readFile.java subdir/file.ext
But now imagine that you want to have it read a remote file, but the app doesn't support that. But JBang already has all the code necessary to download and cache files locally. So why not have some special syntax that lets JBang handle that? For example:
jbang run readFile.java @https://example.org/subdir/file.ext
We'd look for any arguments starting with @http:// or @https:// and replace them with paths to cached versions of those files.
To escape this we could do @@http://, which would then be replaced with the literal @http://.
I've considered the same. Especially in Context of byteman.
The issue is if we wanna optimize startup and generate Direct launch jbang wont be part of the launch.
So been hesitant to add it.
Well in those cases it will obviously don't work :-) To me it's something that JBang adds that the plain app doesn't support, just as it adds auto-dependency lookup and download.
But that means:
'jbang myapp.java' and './myapp.java'
Will behave different from
'myapp' ....
Not great.
Maybe condition this on we get startup reduced so we don't need to skip jbang ? :)
Well there will always be a difference IMO. A user could always do an export and run the app directly that way and it wouldn't work either. So personally I see no problem with cool extras that jbang provides that you won't get if you run the app directly.
Maybe condition this on we get startup reduced so we don't need to skip jbang ? :)
We definitely need to do that too :-) But I wouldn't necessarily wait until we get that done. Perhaps it would give us yet another reason to fix the startup times :-D