jbang icon indicating copy to clipboard operation
jbang copied to clipboard

Add scaffolding templates for groovy with picocli

Open benignbala opened this issue 3 years ago • 6 comments

Is your feature request related to a problem? Please describe. It would be convenient to have templates defined to create project scaffolds with groovy and picocli

Describe the solution you'd like Adding qute templates for initialising a groovy based cli project with picocli

Describe alternatives you've considered Alternative would be to initialise a hello groovy based project and manually add picocli dependencies

Additional context N/A

benignbala avatar Mar 07 '22 17:03 benignbala

I can try and raise a PR for this if others consider this idea/feature request useful.

benignbala avatar Mar 07 '22 17:03 benignbala

Hey, Where would you like to add these templates? Into this JBang repository? JBang catalog is a good place to place your templates in it, you can create it in any git repository and you can wire those templates into your local environment with catalogs.

nandorholozsnyak avatar Mar 08 '22 18:03 nandorholozsnyak

@nandorholozsnyak - Initial thought was to have it in jbang repo so that all users will be able to use it. Please let me know your thoughts on that.

But being able to use from any git repo would be great. In the doc, I saw examples for catalogs and aliases, but they did not show using templates from a different repo. Could you please help me with how to pull in templates from a different repo? Will it be something like the usage below? Thanks


jbang alias --name groovy-picocli https://some.url/path/to/groovy-picocli-jbang.qute
jbang init -t groovy-picocli groovy-cli-util.groovy

benignbala avatar Mar 09 '22 00:03 benignbala

Hey @benignbala

Yes it looks like this, your templates in the catalog are having "names" or at least "keys", as it sits in a JSON Map. When you add this catalog to your local environment you can add a nem for it as you did but when you run the init command you should reference that catalog where you want to read the template from like in this format: jbang init -t=<template-name>@<catalog-name> <filename>

jbang catalog add --name groovy-picocli https://some.url/path/to/groovy-picocli-jbang.qute   
jbang init -t groovy-picocli@groovy-picocli groovy-cli-util.groovy

But I advice you to add a general name to your catalog and not the same as your template.

For example here is what I use: https://github.com/nandorholozsnyak/jbang-cloud/blob/main/jbang-catalog.json

jbang catalog add --name jbang-cloud https://github.com/nandorholozsnyak/jbang-cloud/blob/main/jbang-catalog.json
jbang init  -t=q-aws-lambda@jbang-cloud Lambda.java

It will use that template: https://github.com/nandorholozsnyak/jbang-cloud/blob/main/jbang-catalog.json#L51

nandorholozsnyak avatar Mar 09 '22 06:03 nandorholozsnyak

jbang catalog add --name groovy-picocli https://some.url/path/to/groovy-picocli-jbang.qute

In your first example the URL would have to be to a catalog, not directly to the template. Your second example is correct though 👍

Btw, if you put your catalog in a GitHub, GitLab or BitBucket repo then you don't need to use the jbang catalog add, it will be automatically inferred. So you can do something like this:

jbang init -t helloworld@maxandersen hello.java

and it will just work. And if you don't want to call your repo jbang-catalog then you can also use something like:

jbang init -t helloworld@githubuser/myreponame hello.java

(this is just an example, it won't actually work).

quintesse avatar Mar 09 '22 10:03 quintesse

Thanks a lot @quintesse and @nandorholozsnyak. This helps a lot. I'll try this out.

benignbala avatar Mar 09 '22 13:03 benignbala