From 2a7785cb420c6c154b72d95c91822f9a96d4b598 Mon Sep 17 00:00:00 2001 From: lsh <596060075@qq.com> Date: Mon, 18 May 2026 14:38:42 +0800 Subject: [PATCH] feat(template): add cargo metadata defaults --- Cargo.toml | 16 +++++++++++++--- README.en.md | 5 ++++- README.md | 5 ++++- cargo-generate.toml | 5 +++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e1a34be..cc58976 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,22 @@ name = "rct" version = "0.1.0" edition = "2024" -authors = ["lsh "] -description = "Rust code template." +rust-version = "1.85" +publish = false +authors = ["{{ authors }}"] +description = "{{description}}" readme = "README.md" -repository = "https://github.com/lhui-dev/rct" +repository = "{{repository}}" license = "MIT" keywords = ["template", "rust", "project"] categories = ["development-tools"] [dependencies] + +[lints.rust] +unsafe_code = "forbid" + +[lints.clippy] +dbg_macro = "deny" +todo = "deny" +unwrap_used = "warn" diff --git a/README.en.md b/README.en.md index 422ea50..b894c1b 100644 --- a/README.en.md +++ b/README.en.md @@ -46,6 +46,7 @@ No boilerplate setup. No repeated configuration. Just focus on building. * `cargo clippy` + `cargo fmt` * `typos` spell checking +* Includes baseline lint rules and a declared minimum Rust version ### 🔐 Dependency Safety @@ -190,10 +191,12 @@ cargo deny check ## ⚙️ Customization -Supports `cargo-generate.toml` for template variables like `description`. +Supports `cargo-generate.toml` for template variables such as `description`, `authors`, and `repository` in `Cargo.toml`. After generating a project, update the repository URL in `cliff.toml` to match your own repository. +The template still keeps a fixed package name `rct` so the template repository itself remains buildable with `cargo check`. If you want the package name to be generated too, I can convert it into a pure template setup next. + --- ## 🤝 Contributing diff --git a/README.md b/README.md index cd740b7..c3b2511 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ * 集成 `cargo clippy` + `cargo fmt` * `typos` 拼写检查 +* 默认包含基础 lint 约束与 Rust 版本声明 ### 🔐 依赖安全 @@ -204,10 +205,12 @@ cargo deny check ## ⚙️ 模板自定义 -支持通过 `cargo-generate.toml` 定义模板变量,实现初始化时动态替换,例如 `description`。 +支持通过 `cargo-generate.toml` 定义模板变量,实现初始化时动态替换,例如 `Cargo.toml` 中的 `description`、`authors` 和 `repository`。 生成项目后,记得把 `cliff.toml` 里的仓库地址改成你自己的仓库地址。 +当前模板仍保留固定包名 `rct`,这样模板仓库本身还能继续正常执行 `cargo check`;如果你希望生成时连包名也一起改,我可以继续把它改成“纯模板模式”。 + --- ## 🤝 贡献 diff --git a/cargo-generate.toml b/cargo-generate.toml index 73832f9..b88b3ce 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -9,3 +9,8 @@ ignore = [".idea", "target", "CHANGELOG.md"] type = "string" prompt = "What does your project do?" default = "A Rust project." + +[placeholders.repository] +type = "string" +prompt = "What is your repository URL?" +default = "https://github.com/your-username/your-repo"