37 次发布
0.1.60 | 2023年11月16日 |
---|---|
0.1.59 | 2023年10月28日 |
#422 in 开发工具
每月 327 次下载
88KB
1.5K SLoC
amble
一阶、可扩展的 Rust 项目生成器,内置各种功能。 Amble 是 https://github.com/refcell/amble/labels/stable
安装 | 用户文档 | Crate 文档 | 参考 | 贡献 | 许可
什么是 amble?
amble
是一个生成带有内置功能的 Rust 项目的命令行应用程序。通过使用工作区和子 Crates,amble
可以扩展到任意数量的 Crates。
您可以将 amble
视为 cargo init
的扩展。Cargo 提供了 便捷方法 来生成新的项目结构,两种主要类型是库或二进制项目。以下是使用 cargo init --lib
生成的目录结构的示例。(二进制项目只会在 main.rs
文件而不是 lib.rs
文件中有所不同)。
project
├─ Cargo.toml
└─ src
└─ lib.rs
amble
提供了一个更全面的 CLI 命令,用于使用 工作区 生成项目目录结构。库子crate 嵌套在规范 crates/
目录中,而二进制crate则嵌套在 bin/
目录中。顶层的 Cargo.toml
文件定义了一个工作区,包括二进制和库以及共享的包元数据和依赖项,最小化了子crate之间的一致性问题。amble
还公开了 --lib
和 --bin
标志,这些标志回退到 cargo init
并创建包含所有 amble
配件并可通过 CLI 标志访问的默认 cargo init
文件结构。
以下是当 amble
以 project
作为项目名称运行时的瀑布式目录结构示例。
project
├─ Cargo.toml
├─ bin
│ └─ example
│ ├─ Cargo.toml
│ └─ src
│ └─ main.rs
└─ crates
└─ common
├─ Cargo.toml
└─ src
└─ lib.rs
如以下 用法 中所述,此输出是通过运行 amble project --dry-run
生成的。
用法
使用 cargo 安装 amble
。
cargo install amble
或者,可以从源代码构建 amble
。
git clone [email protected]:refcell/amble.git && cd amble
cargo build --release
要运行 amble
,建议首先以干燥模式运行它,这将打印出在运行时没有干燥模式会创建的文件的水落式目录结构。只需运行 amble <project_name> --dry-run
即可,其中 <project_name>
是您想要创建的项目/目录的名称。
默认情况下,amble
使用当前目录作为项目名称,因此运行 amble --dry-run
是完全可以接受的,这将仅使用 .
作为项目路径。注意,如果 amble 在您选择的执行目录中找到 cargo 艺术品,它将退出。
要从干燥模式运行 amble
,只需运行 amble
!
可以通过将 --with-ci
标志传递给 amble
自动生成预定义的 github 动作 ci 工作流程。这将生成以下目录结构(amble --dry-run --with-ci
)。
.
├─ Cargo.toml
├─ bin
│ └─ example
│ ├─ Cargo.toml
│ └─ src
│ └─ main.rs
├─ crates
│ └─ common
│ ├─ Cargo.toml
│ └─ src
│ └─ lib.rs
└─ .github
└─ workflows
└─ ci.yml
Amble 还提供了用于生成带有模板型自述文件、GitHub动作CI工作流程和许可等电池的 cargo init
库和二进制项目的跳过方法。传递给 cargo init
操作的标志是注入的,这意味着 amble --bin
将传递到 cargo init --bin
,而 amble --lib
将传递到 cargo init --lib
。像往常一样,可以提供任何其他有效的 amble 标志,同时使用 --lib
和 --bin
标志。
CLI 标志
以下是不完全的 CLI 标志列表。这些可能会更改,并且可以添加新的标志。要查看更新的列表,请在本地运行 amble --help
命令。
First class, scalable rust project generator with batteries included.
Usage: amble [OPTIONS] [PROJECT_DIR]
Arguments:
[PROJECT_DIR] The path to the project directory. By default, the current working directory is used. If any rust artifacts are detected in the specified or unspecified directory, an error will be thrown [default: .]
Options:
-v, --v... Verbosity level (0-4)
--dry-run Dry run mode. If this flag is provided, the cli will not execute commands, printing the directories and files that would be created instead
--overwrite Overwrite existing files. If this flag is provided, the cli will overwrite existing files
--bare Bare mode. Only for `--bin` and `--lib` flags. If specified, generated files will be the basic `cargo init` files
-n, --name <NAME> The project name. This will be used for the binary application name [default: example]
-w, --with-ci Add github actions ci workflow
-c, --ci-yml <CI_YML> Copy the specified ci workflow file to the project's `.github/workflows/` directory
-a, --authors <AUTHORS> Override the project authors
-b, --bin Builds a cargo binary project
-l, --lib Builds a cargo library project
--without-readme Prevents a readme from being generated
--full Full generates a full project structure including license, ci, gitignore, etc
--etc Adds an `etc/` directory to the project. This _Et Cetera_ directory is used for storing miscellaneous files
--assets Adds template assets to the `etc/` directory of the generate project. Will be run automatically if the `--full` flag is provided
--license Adds an MIT License to the project. The MIT License type can be overridden with the `--with-license` flag
--gitignore Adds a Gitignore file to the project
-d, --description <DESCRIPTION> Specifies the description of the project in the top-level `Cargo.toml` workspace
--dependencies <DEPENDENCIES> Adds these dependencies to the top-level `Cargo.toml` workspace alongside the default dependencies
--list Lists the default dependencies
--with-license <WITH_LICENSE> License Override. This will override the default MIT License. The license type must be a valid SPDX license identifier
-h, --help Print help
-V, --version Print version
您可以通过运行 amble --help
生成此输出。
贡献
欢迎所有贡献!鼓励实验,并欢迎提出新的问题。
故障排除 & 错误报告
请检查现有问题以查找类似的错误,如果没有相关的问题已存在,请打开一个新问题。
许可
该项目采用 MIT 许可 许可。免费且开源,永远。 我们所有的 Rust 都属于你。
依赖
~32–48MB
~583K SLoC