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

support generating classpaths embedded on command line #1703

Closed
maxandersen opened this issue Nov 13, 2023 · 4 comments · Fixed by #1707
Closed

support generating classpaths embedded on command line #1703

maxandersen opened this issue Nov 13, 2023 · 4 comments · Fixed by #1707
Labels
ideas Some idea/suggestion around jbang behavior/feature set

Comments

@maxandersen
Copy link
Collaborator

I find that sometimes cli's out there need a classpath and it can be quite tedious to type out.

I wonder if like done in #1043 where %{url} fetches content and make it available as a file we could support %{deps://DEPS syntax} to generate classpath.

i.e.

jbang sqlline@maxandersen -cp %{deps:org.hsqldb:hsqldb:RELEASE,..} other args

@maxandersen maxandersen added the ideas Some idea/suggestion around jbang behavior/feature set label Nov 13, 2023
@maxandersen
Copy link
Collaborator Author

@quintesse tell me if i'm crazy or we should just do this :)

@quintesse
Copy link
Contributor

quintesse commented Nov 13, 2023

It doesn't seem totally crazy, no.
But do we have a clear use-case where this enables something we can't do in another way?

Because I don't think you're interested in passing in the classpath as an argument to a script, right? (Which is what %{url} was meant for)

Edit: wait, I now re-read your example and see that you do actually suggest that. Ok, then yes, it seems like a perfect example of something like that.

Not sure if I'd go with the deps: though. I mean, if we're able to detect the difference in JBang between running something as a URL or a Maven dependency, we should be able to do the same for %{ ... } , right?

Something like %{ url | deps } or simply %{ url | dep } (singular dep), because you can always just put several %{ ... } on a line.

@maxandersen
Copy link
Collaborator Author

My usecase is https://github.com/jupyter-java/jbang-catalog/blob/main/installkernel.java where some of kernels especially the kotlin one expects a seperate classpath list as argument.

Similar to the sql drive tooling above.

Reason for deps: prefix is that we allow https urls to GitHub repo as deps too which would need treating differently i think?

@quintesse
Copy link
Contributor

Reason for deps: prefix is that we allow https urls to GitHub repo as deps too which would need treating differently i think?

You're probably right. I don't think it would be impossible to come up with a scheme where we wouldn't have to use the prefix, but it might mean that we'd have to choose one interpretation over another.

Still, I like the simplicity of %{org.hsqldb:hsqldb:RELEASE}. Perhaps we can make the prefix(es) optional where they work to force one interpretation over another when the contents is ambiguous? Eg: %{org.hsqldb:hsqldb:RELEASE} would be ok, because it's obviously not an URL. The same with %{http://www.google.com}. But the issue would be %{https://github.com/jbangdev/jbang}.

In that case we can add the option to add a prefix: url or dep. I think it's good to have both for consistency.

And then we can use:

%{url:https://github.com/jbangdev/jbang}

and

%{dep:https://github.com/jbangdev/jbang}

(Btw, using "dep" here for the examples, but we can do "deps" too of course.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ideas Some idea/suggestion around jbang behavior/feature set
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants