cargo-generate/cargo-generate

cargo, make me a project

cargo-generate is a developer tool to help you get up and running quickly with a new Rust

cargo-generate

cargo, make me a project

cargo-generate is a developer tool to help you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template.

Here's an example of using cargo-generate with this template:

Documentation

See the cargo-generate guide for complete documentation.

Quickstart

Installation

Usage

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or opensource.org/licenses/MIT)

at your option.

Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. If you want to contribute to cargo-generate, please read our CONTRIBUTING notes.

cargo-generate would not be what it is today without the wonderful contributions from the community. Thank you!

Issues

Collection of the latest Issues

taurr

taurr

Comment Icon0

PRE

  • Currently pre hooks are run after all placeholders mentioned in cargo-generate.toml has been resolved.
  • The hooks are free to add aditional variables, but its too late to influence the conditional system.

This is a sideeffect of conditionals influencing the hooks - so placeholders need to be evaluated before the hooks are known.

POST

  • Post scripts are run after template expansion, but before final output is moved to the final destination.

Why not later? Security, and the fact that a failing scrips still causes no errors in the users destination.

taurr

taurr

Type: Enhancement
Comment Icon3

When using cargo-generate with a multi template repository, cargo-generate creates a choice prompt for the user to select a template to expand.

It would help on usability if it was possible to influence this prompt.

  1. It should be possible to specify the default selected template.
  2. It would be nice if the template author could specify the sorting order, or specify the list of templates manually.
laundmo

laundmo

Type: Enhancement
Comment Icon6

It would be nice if it was possible to make templates default to a different or no VCS initialisation. In my case this would be useful for a "minimal" template meant for messing around inside. Could also be useful for templates which are meant to be a smaller part of a larger vcs repository.

As a workaround I tried to delete the initialised vcs repository from rhai, but that doesn't work as rhai scripts run before vcs initalisation.

laundmo

laundmo

Comment Icon3

When running cargo generate with a Git path or URL on Windows 10 (19042) i get the following error:

cargo generate ashleygwilliams/wasm-pack-template (using the example template from the readme)

The same happens when using cargo generate https://github.com/ashleygwilliams/wasm-pack-template.git, or when running the command with elevated permissions.

When cloning the template first and then using the --path flag, i'm able to generate the project.

VirtualNonsense

VirtualNonsense

Comment Icon12

Hello! I'm currently struggling getting this tool to work properly with ssh. Generating from github using https works fine. I have no issues using git by itselve, but for some obscure reason cargo generate does not play nicely with it. Here is the error I am presented with after trying to clone a simple template of mine:

I've seen that there seems to be an issue with passphrase protected keys so I made sure mine does not have one. I also tied an ed25519 key but it did not change the result as well. I feel like I'm missing something obvious and would appreciate some guidance😅

My system: Win11: Version 21H2 rust: rustup 1.24.3 cargo 1.61.0 rustc 1.61.0 cargo-generate 0.14.0

Nothing4You

Nothing4You

Comment Icon1

Hi,

I'm using zdiff3 as diff style in my ~/.gitconfig:

This feature was introduced in Git 2.35.

When trying to generate a project it just hard fails: cargo generate --git https://github.com/rustwasm/wasm-pack-template

Environment: cargo-generate 0.13.0 cargo 1.59.0 (49d8809dc 2022-02-10) rustc 1.59.0 (9d1b2106e 2022-02-23)

CobaltCause

CobaltCause

Type: Enhancement
Comment Icon4

The book has the following to say about this:

cargo-generate will not allow any existing files to be overwritten and will fail to generate any files should there be any conflicts.

I actually think this would be a good feature to have, although the default choice of refusing to overwrite is good. Perhaps an --overwrite flag could be added to generate over the existing project anyway?

For an example use case, I have this template that receives relatively frequent updates since Nix Flakes are still evolving. I feel like an --overwrite option would make it easier to propagate these changes and new best practices to existing projects generated from this template. Then one could do cargo gen ... --overwrite && git restore -p . instead of having to figure out how to apply all of the changes manually.

zeenix

zeenix

Comment Icon5

After an entire day of trying to debug why cargo-generate simply ignores one of my files, it turns out that it was because it used a variable substitution next to a {. Here is my simple reproducer:

Notice how the main.rs is simply ignored and there's nothing reported about that file. I understand if they is a known limitation that can't be fixed easily but then cargo-gen should report that or error out.

sassman

sassman

Comment Icon0

we need an example chapter in the book,

that links the existing examples and elaborates on the details of them. The goal is to guide template authors thru the features and what can be achieved by them.

xoac

xoac

Type: Enhancement
Comment Icon7

Hi, I wanted to create a template that allows me to create a project within URL. The question about project-name in most cases is in GitHub link and this is in my opinion, the best approach in creating a new project from template. The project-name variable must be required, but checking about its absence should be postponed until all pre-hooks are called.

This is a pseudo dialogue I want to achieve:

Past link to repository of your project: <github.com/organizaton/my-awesome-rust-project> Is the name of your project correct my-awesome-rust-project? [Y (Yes)/e (Edit)] Your project is created!!

To make this backward compatible the template should set options that allow it to set project-name on it's own. For example in cargo-generate.toml template.project-name.ask = false (default true)

What do you think about this idea?

sassman

sassman

Type: RFC
Comment Icon3

As a template author I want to have an easy way to test my template code So that I save time to manually generate a project, run then cargo test in it and delete the generated project again

I imagine something like

jashandeep-sohi

jashandeep-sohi

Type: Enhancement
Comment Icon3

Currently, only RSA keys are supported: https://github.com/cargo-generate/cargo-generate/blob/528bf381807201bf91103dd3ca50bcca90365a5c/src/git.rs#L119

However, more and more people are defaulting to ed25519(myself included). Having to setup a rsa key just for cargo-generate is not ideal.

cargo-generate should at least support ed25519 keys as well.

Edit: I realize I could manually override this via -i | --identity, but my request is to make it automatically use id_ed25519 if it exists.

meteor-lsw

meteor-lsw

Comment Icon13

error: linking with D:/tools/msys2/mingw64/bin/gcc.exe failed: exit code: 1 | = note: "D:/tools/msys2/mingw64/bin/gcc.exe" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o" "-L" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.0.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.1.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.10.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.11.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.12.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.13.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.14.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.15.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.2.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.3.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.4.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.5.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.6.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.7.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.8.rcgu.o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.cargo_generate.elpum516-cgu.9.rcgu.o" "-o" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.exe" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\cargo_generate-322a0567e1bd1f3c.tbu5d0tql07i4k5.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps" "-L" "D:\tools\rust\cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\winapi-x86_64-pc-windows-gnu-0.4.0\lib" "-L" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\build\curl-sys-af3af859703ade0c\out\build" "-L" "D:/tools/msys2/mingw64/lib" "-L" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\build\miniz-sys-dda096bda52d57c7\out" "-L" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\build\libgit2-sys-7ec412b9f75c2d14\out\build" "-L" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\build\libssh2-sys-6202ae920404ab1e\out\build" "-L" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "-Wl,-Bstatic" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libliquid-a856f37089028c34.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libitertools-044a3c7ebe57eb15.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libchrono-d43e036e99ab9175.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libnum_integer-41afb4b9a3d66492.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libnum_traits-5ea7273248b77cba.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtime-af67cc2a0f23cb81.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libindicatif-1a09bf93340bb565.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libregex-16df94e096ada1bc.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libregex_syntax-cbfa75d3e32eb6bd.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libheck-b620118086972baa.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libunicode_segmentation-d500c0645fa2299d.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libdialoguer-ca8db0fb498caaf2.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtempfile-f87c0004fa05a90a.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librand-9eee9644ba90629f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libconsole-fa6e307b89bdfcf5.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libclicolors_control-640d82fe253a46dc.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblazy_static-e105ff82f801dd65.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libkernel32-a3ba73322d2bffcd.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcargo-ecf7d878e1780958.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libmiow-41461ad2c2ba30c9.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrypto_hash-f68db54db9c040a7.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtoml-6cf61ba61cbeed68.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtempfile-4617355f93652106.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libremove_dir_all-02b14a4798917bed.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtar-b6a368df1588c541.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libshell_escape-9bebd1421d960bf2.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libserde_ignored-f0c82ba94e579cf0.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libsemver-ff9e4cc953084670.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libsemver_parser-fe72b8a3198cc28f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librustfix-b336a80bbca59846.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblazycell-9aa3a43a522cd938.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libjobserver-a26603ddafed40e9.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librand-d37858d4f5db9b71.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libignore-08862777c9bcae2f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libwalkdir-52a42bf873692c95.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libsame_file-6a24195975822b76.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libglobset-ab760efa58c17c6e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libfnv-37c543951331ebc5.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_channel-4e36a95d7b5aa8fa.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libparking_lot-619272693a9d98e1.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libparking_lot_core-4e7e83d7bbc99257.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libsmallvec-19521330d8799c32.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libunreachable-b51fa06ab19701d8.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libvoid-02fca20cb3b16c21.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblock_api-91acaf34fae40dcc.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libowning_ref-5e62befec956c970.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libstable_deref_trait-8a22f15585242799.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librand-d98c24f0c2c91ae7.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librand_core-9cf4d34506d01a3b.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librand_core-3d5bd0e6e5311427.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_epoch-8d7910f2e9f47b43.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_utils-c81e0308eb92971a.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libhome-d1e6582e4dc40b76.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libhex-b69485eeb985172e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libgit2-0184e0fd091a7fc6.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblibgit2_sys-97ef8d96dcadc46d.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblibssh2_sys-e2490ead6536ff5e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libfs2-2194860d9b309035.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libflate2-bfa78e9d6b0a47e9.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libminiz_sys-40e3708393e1da5f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libflate2_crc-dbf55099c16d34c8.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libfiletime-0402e4efef9ada0f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_utils-fa509388618477d7.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrates_io-33419572fb832d0d.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liburl-afb10d27d9fd3016.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libpercent_encoding-a355114de0e6db22.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libidna-edec281c5a5e3686.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libunicode_normalization-dcd5297c77dc97ec.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libunicode_bidi-593623e2e567e29f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libmatches-85ff47ecd69a35f2.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libserde_json-80842ccfd836dcb4.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libryu-8fa185226987cfab.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libitoa-81c665a18bc43567.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl-a6500983cf99de10.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libwinapi-738ad2b00ad044db.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libsocket2-88c097ce076aa3cd.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblibz_sys-5123f541428d776f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libquicli-8eeddace8e77fe2c.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libglob-bf303a1735075306.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librayon-132ecb1a286ba1c1.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libeither-7e0e6f3e02880cd6.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librayon_core-f4e2ca328e9c0f70.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libnum_cpus-17343f8950ed4847.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_deque-5558c69bd7e22f8e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_epoch-5e97f64e96407ced.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libscopeguard-80802f48d94e9794.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libmemoffset-c3b9a111149383d5.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcrossbeam_utils-152a39b5da18ce6e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libarrayvec-11bd89e19e0497a5.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libnodrop-c1bbb322ea60c1b4.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libclap_verbosity_flag-e6a05ba413540d28.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libenv_logger-db75c6de78a92ee4.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libregex-41134fd1502a05e9.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libutf8_ranges-4a04e3147b96465f.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libregex_syntax-585b00813f8c6df4.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libucd_util-2ff0197eaf504c81.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libthread_local-b9f3c54fb4fc76db.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblazy_static-f730d61e0410bfdb.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libaho_corasick-f810524dd139a7a7.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libmemchr-7f0582c0b21d58ec.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblibc-de18764d00aa515e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libhumantime-ccc4141ccbd56251.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libquick_error-449b2c3229e442bb.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtermcolor-87761f4f28216508.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libwincolor-333c52afa5e29098.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libwinapi_util-d9138a3eb1d4e87b.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\liblog-f0855e438ecbf127.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libfailure-bf8efacbfcc6a90e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libbacktrace-12ae1d462c6db669.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\librustc_demangle-6c1e6e60d6861f8a.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcfg_if-187834b448f19fc3.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libstructopt-cf9dcf4fc407380a.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libclap-de734b35c6a8c58b.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libvec_map-949606e25430044e.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libtextwrap-f8640948c8c6d1ed.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libunicode_width-1e6dd0e0606990cb.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libstrsim-b9b06c3438835334.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libbitflags-41caf2aeec7d7598.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libatty-3bd152b1e4938760.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libwinapi-9766c4bc1e4292bf.rlib" "C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libserde-6fa5d4a6d6a41b7b.rlib" "-Wl,--start-group" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-e269899800b7f5ee.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-420daa7077b13e1b.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libunwind-d5a63f54c467a91c.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liblibc-1e5b567790a6623b.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc_system-d3d36d79ddf591f9.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc-07cf62366d6c96b4.rlib" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcore-2a100266e0223f8b.rlib" "-Wl,--end-group" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcompiler_builtins-05731d1ceb996d14.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lwinhttp" "-lrpcrt4" "-lole32" "-lcrypt32" "-lbcrypt" "-lcrypt32" "-luser32" "-lws2_32" "-lcrypt32" "-lz" "-lwinapi_advapi32" "-lwinapi_bcrypt" "-lwinapi_credui" "-lwinapi_crypt32" "-lwinapi_cryptnet" "-lwinapi_dbghelp" "-lwinapi_fwpuclnt" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_msimg32" "-lwinapi_ncrypt" "-lwinapi_ntdll" "-lwinapi_opengl32" "-lwinapi_psapi" "-lwinapi_secur32" "-lwinapi_setupapi" "-lwinapi_synchronization" "-lwinapi_user32" "-lwinapi_userenv" "-lwinapi_winspool" "-lwinapi_ws2_32" "-ladvapi32" "-lws2_32" "-luserenv" "-lshell32" "-Wl,-Bstatic" "-lgcc_eh" "-lpthread" "-Wl,-Bdynamic" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "D:\tools\rust\rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsend.o" = note: C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(url.o):url.c:(.text$Curl_init_userdefined+0x10): undefined reference to __imp___acrt_iob_func' C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(cookie.o):cookie.c:(.text$Curl_cookie_init+0x28e): undefined reference to __imp___acrt_iob_func' C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(cookie.o):cookie.c:(.text$Curl_flush_cookies+0x24c): undefined reference to __imp___acrt_iob_func' C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(formdata.o):formdata.c:(.text$Curl_getformdata.part.0+0x266): undefined reference to __imp___acrt_iob_func' C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(setopt.o):setopt.c:(.text$Curl_vsetopt+0x316c): undefined reference to __imp___acrt_iob_func' C:\Users\lws\AppData\Local\Temp\cargo-installFh6koS\release\deps\libcurl_sys-19f68c0f0debfa8d.rlib(mprintf.o):mprintf.c:(.text$curl_mprintf+0x29): more undefined references to __imp___acrt_iob_func' follow collect2.exe: error: ld returned 1 exit status

ashleygwilliams

ashleygwilliams

Comment Icon2

the time has come. the test file is too long. i'd like to see it separated out by category- similar to how our src dir is broken up.

ashleygwilliams

ashleygwilliams

Comment Icon1

i want this to exist for npm init templates- but it doesn't. would be rad if i could compile this to wasm. no idea what the blockers are yet, but i am imagine libgit2 may give us problems... this may be a good reason to resolve #67 by removing libgit2 and shelling out to git (anyone using this tool would already have git installed)

dcarosone

dcarosone

Type: Enhancement
Comment Icon5

In #47, one of the possibilities noted is

sub dir in a repo

I wanted to make a suggestion that's a little more extensive than this, and I think it's enough of an expansion to list as a separate issue.

A number of projects have examples/ directories with cargo support for running them directly, and there's also a proposal to let cargo support larger per-directory examples in a sub-structure under there. These are often good starting points for customising your own code; I know I've done this a number of times, especially with some embedded projects. That sounds a lot like a template!

I think is worth combining these proposals and having some specific conventions to make it easier, such that project example directories can always/automatically be templates. I'd like it to be sufficiently low-friction that neither general crate authors nor template consumers need to do anything much extra or unusual to use examples as templates, and offering templates becomes the norm.

This probably involves some changes on both sides, perhaps something like this:

  • example directories look like templates, with placeholders, and have an example.toml with placeholder values. Cargo knows how to use this when running in-place as an example.
  • this in turn suggests that making a new example (directory) should itself make a bare template (cargo new --example?) so that there's a cohesive story from start to, well, new start :)
  • when given a repo, cargo generate can look in the examples directories to find templates, and (in interactive mode) offer a list to pick from, so that repos can be discoverable as either single templates at the root, or more structured collections.

One of the strongest reasons for this is to keep examples and templates in sync with the libraries they represent; cargo should test each of the templates-as-examples just like today. If they're in a separate repo, there's always a risk they'll languish. If they're in the one repo, examples can also be updated to match library code changes on branches.

anirudhb

anirudhb

Comment Icon9

This would remove the dependency on Git, and we would just link in libgit2. It would require less things to be installed, especially when you start distributing this as a binary, since Rust statically links everything!

rahul-thakoor

rahul-thakoor

Comment Icon12

Hello! I am trying to make a template for creating mdbooks. cargo-generate currently analyses the Cargo.toml file and then tries to replace the placeholders. It would be great to have mdbook templates, however, the book.toml file should be parsed instead. Having a --book flag could direct cargo-generate to parse book.toml. Any suggestions?

Versions

Find the latest versions by id

v0.11.1 - Dec 03, 2021

🛠️ Maintenance

Contributors

v0.10.3 - Oct 11, 2021

🛠️ Maintenance

v0.9.0 - Aug 23, 2021

✨ Features

🛠️ Maintenance

v0.8.0 - Jul 30, 2021

v0.7.2 - Jul 22, 2021

v0.7.0 - Jul 13, 2021

v0.6.0 - Mar 07, 2021

v0.6.0-alpha.2 - Feb 18, 2021

  • ✨ Features

    • interactive variable leads to default, issue/17, by sassman

      This allows for lazy typing when using custom variables in templates, so that a user does not need to type the default value, but rather can press in order to accept the default value that is presented.

v0.6.0-alpha.1 - Feb 15, 2021

v0.5.3 - Feb 08, 2021

v0.5.2 - Feb 03, 2021

  • ✨ Features

    • make args fields public to provide a public API by @No9 , pull/264

      this allows the external usage of cargo-generate from any lib / binary see this example

    • support operating system and architecture by @macalimlim , pull/252, issues/251

  • 🤕 Fixes

    • fix creates an empty .cargo-ok, by @thomcc , pull/269, issues/259

    • apply rust best practices clippy + fmt + ci/cd pipeline by @sassman , pull/273 issue/270

      Make clippy happy, and applies fmt for the whole code base Also, tests, linter (fmt+clippy) on mac, linux and windows are now executed on builds, means also for PRs Dismisses now travisCi and Appveyor

    • handle default branch properly by @cecton , pull/263, issues/258

      Make sure that not master or main as branch name is used and expected, but rather use the git default branch.

  • 🛠️ Maintenance

    • Shrink crate size by @sassman , pull/272

      Applies the suggestions of cargo-diet and hereby helps to reduce the crate size, by ship less irrelevant files.

  • 👯 New Templates

    • godot-rust-template: Create games with Godot and Rust by @macalimlim , pull/248

v0.5.1 - Sep 21, 2020

  • 🤕 Fixes

    • Ignore files in .genignore before walking/substitution - schell, pull/235 [issue/236]

      This fixes scenarios where liquid variables cause parsing errors in files that should be ignored.

    • Fix in CLI help option - SirWindfield, pull/234

      This fix the display of the --branch option in the help message, when executing cargo generate --help.

  • 👯 New Templates

    • generust: a template that provides a Rust web server and WASM client with some interesting features - KyleU, pull/203

    • orbtk: a template that lets you create user interfaces using OrbTk - FloVanGH, pull/214

    • template-rust-backend-with-electron-frontend: a template that lets you write a Rust native cdylib backend with Electron frontend - usagi, pull/218

    • swift-rust-xcode-template: a template that lets you write an iOS app with Swift and Rust - simlay, pull/219

    • Win32: a template that provides an interface to write low-level Win32 applications in Rust - ArmsOfSorrow, pull/220

    • QuickStart WebAssembly: a template that lets you create a WebAssembly application with Rust - PankajChaudhary5, pull/227

    • rust-cli-template: a template that lets you create easily a CLI with interesting features in it (color_eyre, tracing, in addition to benchmarking and testing boilerplate) - 9999years, pull/239

    • mongodb-service-template: a template that lets you create a GraphQL service with MongoDB as backing storage - bdbmammoth, pull/243

  • 🛠️ Maintenance

    • Support for owner/repo abbreviation for git URL format - 9999years, pull/242

    • Usage of default git branch instead of master - 9999years, pull/241

    • Updated cargo-generate to the latest and greatest in the Rust ecosystem - Veetaha, pull/237

      • Update all dependencies versions to latest ones
      • Replace rustfmt-preview with rustfmt
      • Replace failure with anyhow
      • Remove quicli completely
      • Update cargo authors copied code to latest cargo master
      • Fix clippy lints:
        • Replace &PathBuf to &Path in code
        • Remove bare use crate_name entires
        • Replace unexported pub with pub(crate)
      • Apply some cosmetic impl refactorings
    • Code refactoring - SirWindfield, pull/233

    • Support all liquid filters - sassman, pull/225

      • Upgrade liquid to v0.20
      • Enables all liquid default filters
      • Fix some findings of clippy
    • Typo fixes in CONTRIBUTING.md - Darrenmeehan, pull/222

v0.5.0 - Oct 29, 2019

  • ✨ Features

    • Add a verbose flag for printing excluded files - EverlastingBugstopper, pull/199

      cargo-generate can now be run with a --verbose flag that will print the list of files/directories that it is ignoring. This means that by default the output for templates that exclude files will appear no differently from templates that do exclude files.

  • 🤕 Fixes

    • Update two failure scenarios to exit with code 1 - EverlastingBugstopper, pull/198

      When cargo-generate fails due to an issue with git or if a target directory already exists, it will now fail with an exit code of 1.

    • Fix path display on Windows - tommyshem, issue/192 pull/195

      Changes Windows file output from "C:\\Users\\Me\\src\\example-com\\.genignore" to "C:\Users\Me\src\example-com\.genignore"

    • Don't remove .github directory when only .git should be removed - softprops, issue/190 pull/191

      When generating a new project, cargo-generate will remove the .git directory and initialize a new git tree. In doing so, it would remove any file or directory containing .git, including .github. This release fixes that bug!

  • 🛠️ Maintenance

v0.4.0 - Aug 09, 2019

  • ✨ Features

    • Add config file for configuring include / exclude of files to template - xortive, pull/174

      Adds support for the cargo-generate.toml file, which allows templates to configure which files should be processed, either using a whitelist method (include), or a blacklist method (exclude). When both include and exclude are present, include will be preferred. This mirrors similar include/exclude behavior in cargo, and uses some of the same code.

      Include List

      Exclude List

      Invalid Configuration

  • 🤕 Fixes

    • Respect default branch name of template - RotationMatrix, pull/166

      The --branch flag will now work as intended and set the initial HEAD to the specified branch name. For example, running cargo generate --git <gh pages template> --branch gh-pages will set your generated project's default branch to gh-pages.

  • 🛠️ Maintenance

v0.3.1 - Jul 30, 2019

  • 🤕 Fixes

    • Fix messages related to rename behavior - xortive, pull/162

      --force would stop cargo-generate renaming your project, but we would still message that the rename was happening. Not anymore!

    • Use Vendored OpenSSL for macOS - xortive, pull/169

      Our prebuilt binaries for macOS were using dynamically linked OpenSSL, and our CI was dynamically linking to a version of OpenSSL not installed by default on most macs. Now, the macOS release build of cargo-generate will work out of the box utilizing staticly linked, vendored OpenSSL.

  • 👯 New Templates

  • 🛠️ Maintenace

v0.3.0 - Apr 04, 2019

  • ✨ Features

    • Support case filters in templates - epage, issue/117 pull/140

      Because we leverage liquid as a templating engine under the hood, we can add some specific filters to our substitutions to add a little more awesome. This feature adds 4 filters:

      • capitalize
      • pascal_case
      • kebab_case
      • snake_case

      Now we can tame any set of letters with any type of capitalization or dash! Give them a try and let us know what other types of features you'd like to see.

  • 🤕 Fixes

    • Windows releases on Appveyor - jaysonsantos, issue/145 pull/146

      Thanks to a new tool, wrangler, that uses cargo-generate as a dependency, it was discovered that we were shipping broken Windows binaries. We've fixed that now!

  • 👯 New Templates

  • 🛠️ Maintenance

v0.2.2 - Dec 21, 2018

  • 🤕 Fixes

    • fix relative paths to templates - DD5HT, issue/128 pull/129

      When we previously merged the PR in 0.2.0 that leveraged cargo to clone the templates, enabling folks to work with private repositories- we introduced a GitConfig::new function (replacing work done previously by libgit2). This function works great- but did not support relative paths. We didn't catch this because we weren't testing the relative paths usecase!

      With this PR, DD5HT has restored the relative path functionality- and added a test to prevent further regressions of this function!

  • 🛠️ Maintenance

v0.2.1 - Nov 20, 2018

  • 🤕 Fixes

    • don't error on missing .genignore file - DD5HT, issue/116 pull/120

      With 0.2.0 we introduced the idea of a .genignore file, however, we didn't account the situation where one would not be present. Thanks for filing an issue Diggsey and thanks for the quick fix DD5HT!

    • enable use on private repositories- ChristopherMacGown, pull/119

      This PR leveraged cargo to enable the ability to pull authenticated repos. As this project grows into something we'd like to integrate into cargo, this gives us greater functionality and also moves us closer to cargo's codebase. Yay!

    • exclude submodules git metadata - ChristopherMacGown, pull/119

      Two bugs, one PR! Adding a test found that git metadata wasn't being excluded from submodules- now it is! Thanks so much!

  • 👯 New Templates

v0.2.0 - Oct 08, 2018

  • ✨ Features

    • Support templates that use git submodules - k0pernicus, issue/83 pull/104

      We now support templates that use git submodules! Yay!

    • Binary Releases for Linux, MacOS, and Windows - ashleygwilliams, issue/99 pull/111 pull/112

      Motivated by a desire to more easily distributed the project - we now build binaries for our releases. No more waiting for compilation! You can just download and go!

    • Allow Liquid Templating date filter - ashleygwilliams, issue/70 pull/106

      By request, we've turned on the date filter for our templates. Now you can add nicely formatted dates to your projects! For more information, check out the Liquid date filter documentation.

    • Add .genignore, ability to ignore files - DD5HT, issue/82 pull/96

      You can now add a .genignore file to your template. This file will specify the files to be "cleaned up" or "removed" from the template once it has been cloned to the user's local machine.

    • Add --branch for specifying a branch - posborne, issue/71 pull/94

      We originally had no way to specify a git template on a per branch basis, opting to only support the primary branch. Now you can specify a branch:

    • Warn user if we change project name casing - k0pernicus, issue/65 pull/84

      cargo-generate will automagically "fix" the casing of your project name to match Cargo standards. If we end up changing the name you provide- we'll warn to let you know!

    • Add --force flag to skip casing check on project name - toVersus, issue/66 pull/69

      cargo-generate will automagically "fix" the casing of your project name to match Cargo standards. If you'd like to skip that, you can add --force.

    • Add short flag -n for --name - DD5HT, issue/73 pull/77

    • List of available templates - ashleygwilliams, issue/74 issue/50 pull/75

      We are now keeping a running list of templates that are available to use with cargo-generate. Please add more!

    • Add short command cargo gen - DD5HT, issue/53 pull/72

      You can now use cargo gen as a short command for cargo generate.

    • 🛠️ Maintenance

Information - Updated Jun 15, 2022

Stars: 1.0K
Forks: 104
Issues: 29

Cargo-xbuild is a replacement for xargo which is now no longer supported

Cross compling sysroot features can be specified in the command line parameters or via cargo config

Cargo-xbuild is a replacement for xargo which is now no longer supported

Cargo Advent of Code Helper

cargo-aoc is a simple CLI tool that aims to be a helper for the Criterion

Cargo Advent of Code Helper

cargo-tree has been integrated directly into Cargo as of the 1

This repository is archived as a result

cargo-tree has been integrated directly into Cargo as of the 1

cargo-ndk - Build Rust code for Android

This cargo extension handles all the environment configuration needed for successfully building libraries

cargo-ndk - Build Rust code for Android

cargo-all-features

Cargo subcommands that build and test all feature flag combinations for a crate

cargo-all-features

cargo-geiger ☢️

A program that lists statistics related to the usage of unsafe Rust code in a Rust

cargo-geiger ☢️

cargo-io-lib-template

This is tweaked cargo init --lib for FOSS

cargo-io-lib-template

cargo-spellcheck

Grammar check using on how to define a custom dictionary file

cargo-spellcheck

cargo-cov: Source coverage for Rust

cargo-cov is a cargo subcommand which performs source coverage collection and reporting for Rust crates

cargo-cov: Source coverage for Rust

cargo-raze: Bazel BUILD generation for Rust Crates

An experimental support Cargo plugin for distilling a workspace-level

cargo-raze: Bazel BUILD generation for Rust Crates
Facebook Instagram Twitter GitHub Dribbble
Privacy