Favorites

Favorite templates can be defined in a config file, that by default is placed at $CARGO_HOME/cargo-generate.toml or $CARGO_HOME/cargo-generate. To specify an alternate configuration file, use the --config <config-file> option.

⚠️ NOTE: A relative --config option, will be relative to the template root during expansion.

Each favorite template is specified in its own section, e.g.:

[favorites.demo]
description = "<optional description, visible with --list-favorites>"
git = "https://github.com/ashleygwilliams/wasm-pack-template"
branch = "<optional-branch>"
subfolder = "<optional-subfolder>"

Values may be overridden using the CLI arguments of the same names (e.g. --subfolder for the subfolder value).

When favorites are available, they can be generated simply by invoking:

cargo gen <favorite>

or slightly more involved:

cargo generate demo --branch mybranch --name expanded_demo --subfolder myfolder

⚠️ NOTE: when <favorite> is not defined in the config file, it is interpreted as a git repo like as if --git <favorite>