-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add template option to cargo-new command? #396
Comments
I think that use cases like "generate a new nickel project" belong in a |
@steveklabnik I agree, I don't think cargo should care about nickel or any other project for that matter. What I'm suggesting is more the functionality to take a project template and scaffold a project based on that. It would allow for the creation of more than the simple lib or bin setup available currently. The templates would be external, and maintained by a 3rd party. So the reponsibility of maintaining the templates would be on whoever developed them in the first place. Fair point on the Django example. |
Leiningen, the Clojure equivalent of Cargo, does something much like this: https://github.com/technomancy/leiningen/blob/stable/doc/TEMPLATES.md |
The |
Its been a while since I looked at this originally. Getting back into it today and wondering, what do you think of using rust-mustache for these templates? It would mean that the command would download the template files, compile each one as a mustache template then write them out to the target directory. If not rust-mustache, is there a different preferred template system that would be ok to use here? |
Project templates allow users to define custom templates which can be used to scaffold projects. These templates consists of a directory of files, each of which will be treated as a mustache template. Example: cargo new myproject --template=http://github.com/someone/nickel-template This would download the template called 'nickel-template' to ~/.cargo/templates/nickel-template. Each file in that directory would then be compiled and rendered to the new project directory created by cargo. Once the template is downloaded, future uses can just reference it by name: cargo new webapp --template nickel-template Certain files will be ignored in template directories. These are namely files which mustache will not be able to compile. Image files, for example are all ignored. Closes issue rust-lang#396
I think it looks great so far, however from a interface viewpoint I would like to see 2 additions:
|
So it isn't super extensive right now, but I have a cargo subcommand here: https://github.com/pwoolcoc/cargo-template that does something like this. Currently "templates" are really just existing cargo projects, and I fill in the |
@alexcrichton yea thanks, I was told about that PR after I posted my project to /r/rust. I guess my github-search-fu wasn't good enough. I'm excited for #3004 to land! |
I think this can be closed now. |
I'm wondering what you think of extending the
cargo new
command to allow users to specify a template which will be used to scaffold the project.For example:
Where
nickel-rs-template
is a repository containing a sample nickel.rs app with some placeholder values which would get replaced when being generated.An advantage of this is that 3rd party developers could create and maintain templates for working for their project. For instance the example I've listed above could allow developers to quickly generate a "hello world" nickel.rs web application.
The idea behind this is similar to that seen in Django:
django-admin.py startproject --template=xxx
.I'd be happy to work on this, but wanted to see if it's something that may be useful and get any feedback / thoughts on it before beginning.
The text was updated successfully, but these errors were encountered: