Proposal: Download project templates with crystal init

Hi there,

What would you guys think about allowing crystal init to receive as an argument a URL with a project template? of course, some files in the project would require to be ECR templates so the project name is properly inserted. As a bonus, there could be a flag like template-arguments in which the user could pass a list of key value pairs with parameters for the project.

Ultimately, it could look like:

$ crystal init myapp --url=http://github.com/coolframework/template --template-arguments db_engine=postgres

Of course you could question how is this useful or why is it required. I believe there are several advantages:

  1. I like to think that crystal best practices would tend to evolve faster than the language. Or at least there could be useful setup that can be shared with others (I thought about this when adding GitHub Actions for publishing a CLI App I created, and thought there should be a simple way to share that with others).

  2. Organizations could leverage this by providing their users with pre-approved project templates for say, micro services, that serve some standard.

  3. It gives framework creators the leverage for creating boilerplate without creating that infrastructure themselves (think about rails, in which you need rails for setting up a rails project in which rails is included as a dependency).

So what do you guys think? I’ll be willing to give it a try at the implementation if you feel this would be a cool addition to crystal.

4 Likes

Related: https://github.com/crystal-lang/crystal/issues/8844.

Wow, thanks @Blacksmoke16 that was fast. If I read correctly the proposal was to add a wizard or ultimately remove this functionality from the crystal command completely, since the wizard adds a certain level of complexity and maintenance burden that may be too much for the maintainers. I just basically re-posted this in the issue since I think it can contribute to the discussion a little bit.