jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.4k stars 156 forks source link

cant add xam.dk nor apache/camel to a catalog #1746

Open maxandersen opened 7 months ago

maxandersen commented 7 months ago

not sure if this is a bug or not....but I can do:

jbang catalog add --name xam.dk xam.dk even though I can do jbang catalog list xam.dk

shouldn't we allow aliases with .'s or is that going too far to be able to list https://... based catalogs?

maxandersen commented 7 months ago

i just realised you also can't add apache/camel ...nor jbanghub/eclipse using the CLI but you can do it when editing the json directly.

its quite nice being able to list catalogs this way....should we lift the restriction on the cli or you consider this a bug and thus shouldn't be able to list these names ?

quintesse commented 7 months ago

Well, in the JSON you can of course put whatever you like, it's supposed to be "safe". Just never thought about EvilMax trying to edit his way out of CLI restrictions :-)

The reason for the limit has more to do with the fact that if you allow a bunch of special characters in alias names you run the risk of ambiguities: things that look like URLs or implicit catalog references, or Maven GAVs etc, and that right now get flagged as such, and things that are supposed to be aliases. But it's not as if I've listed all the possible ambiguities, it was more of a "safe bet".

maxandersen commented 7 months ago

I know we treat names with . as then it must be a http url - but that afaik is after alias resolution (haven't double checkked) so if thats true it should be fine..? and even if we dont do it for hostnames - it feels to aliases with /'s in it should be allowed if not for anything but you can make catalog that lists other implictly named catalogs...could even consider adding criteria that the catalog alias is equivalent to the implicit alias if wanna be on safe side?

quintesse commented 7 months ago

you can make catalog that lists other implictly named catalogs

I don't think that makes any sense, I could imagine being able to use implicit catalog names as the value of a catalog ref but not as it's name. I mean, what's the point? Isn't foo/bar meant to indicate a repo called "bar" in an org called "foo" (either on github, gitlab or bitbucket)?

What's the specific use-case of allowing alias names with slashes (or .s for that matter)? After all an alias is just a name that you give to something more complex that you don't want to type each time. But I have the feeling you want to use it for "fakery" (pretending to be something, like an implicit catalog or a URL, when you're really an alias)

quintesse commented 7 months ago

Btw, I just remembered that JBang, internally, does make use of the fact that we can give aliases names with special chars. Heck we even store entire URLs it seems (although I have no idea why). This is done so we don't need to go look up the value of @maxandersen each time, otherwise we'd have to do the lookup in github, gitlab or bitbucket each time.

So to be honest I just don't know what's right or wrong anymore :-)

maxandersen commented 7 months ago

you can make catalog that lists other implictly named catalogs

I don't think that makes any sense, I could imagine being able to use implicit catalog names as the value of a catalog ref but not as it's name. I mean, what's the point? Isn't foo/bar meant to indicate a repo called "bar" in an org called "foo" (either on github, gitlab or bitbucket)?

What's the specific use-case of allowing alias names with slashes (or .s for that matter)? After all an alias is just a name that you give to something more complex that you don't want to type each time. But I have the feeling you want to use it for "fakery" (pretending to be something, like an implicit catalog or a URL, when you're really an alias)

The usecase is to have jbang catalog list show list of aliases using their implicit aliases.