2 个版本 (1 个稳定版)
使用旧 Rust 2015
1.0.0 | 2018年7月18日 |
---|---|
0.1.0 | 2018年6月18日 |
#401 in Cargo 插件
145KB
3K SLoC
cargo-culture
概述
Cargo 子命令,提供对 cargo-culture-kit 默认规则的便捷访问,并为规则检查二进制文件的开发提供示例。
入门指南
依赖项
cargo-culture
是一个 Rust 项目,它使用标准 Rust 工具链中的 cargo
管理其依赖项。
构建
对于本地程序开发,您可以使用以下命令构建 cargo-culture
- 下载项目仓库
git clone https://github.com/PolySync/cargo-culture.git cd cargo-culture/cargo-culture
- 执行构建
cargo build
安装
您可以直接从 crates.io 安装 cargo-culture
。
- 使用 cargo 内置的二进制安装命令
cargo install cargo-culture
- 或者,您也可以使用本地仓库克隆安装
git clone https://github.com/PolySync/cargo-culture.git cd cargo-culture/cargo-culture cargo install
用法
使用 cargo-culture
的最简单方法是直接在 Rust 项目的根目录下运行它
cd my_rust_project
cargo culture
- 更详细的用法
$ cargo culture --help USAGE: cargo culture [FLAGS] [OPTIONS] FLAGS: -h, --help Prints help information -V, --version Prints version information -v, --verbose If present, emit extraneous explanations and superfluous details OPTIONS: --culture-checklist-path <culture_checklist_file_path> The file location of the line-separated list of Rule descriptions to check for this project --manifest-path <manifest_path> The location of the Cargo manifest for the project to check [default: ./Cargo.toml]
示例
-
运行
cargo culture
对需要一些工作的 Rust 项目的默认规则可能如下所示$ cargo culture Should have a well-formed Cargo.toml file readable by `cargo metadata` ... ok Should have a CONTRIBUTING file in the project directory. ... FAILED Should have a LICENSE file in the project directory. ... ok Should have a README.md file in the project directory. ... ok Should have a rustfmt.toml file in the project directory. ... FAILED Should have a file suggesting the use of a continuous integration system. ... FAILED Should `cargo clean` and `cargo build` without any warnings or errors. ... ok Should have multiple tests which pass. ... ok Should be under source control. ... ok Should be making an effort to use property based tests. ... ok culture result: FAILED. 7 passed. 3 failed. 0 undetermined.
-
您可以使用
--manifest-path
选项执行cargo culture
对当前工作目录之外的项目进行检查。cargo culture --manifest-path $HOME/some/other/project/Cargo.toml
-
要应用可用规则的一个子集,您可以在项目目录中提供一个
.culture
文件。此文件应包含用行分隔的Rule
描述列表。$ cat > .culture << EOL Should have a LICENSE file in the project directory. Should have a README.md file in the project directory. EOL $ cargo culture Should have a LICENSE file in the project directory. ... ok Should have a README.md file in the project directory. ... ok culture result: ok. 2 passed. 0 failed. 0 undetermined.
-
您还可以通过提供
--culture-checklist-path
选项从特定位置的选择清单文件中选择规则的一个子集。$ cat > my_culture_checklist.txt << EOL Should have a LICENSE file in the project directory. Should have a README.md file in the project directory. EOL $ cargo culture --culture-checklist-path my_culture_checklist.txt Should have a LICENSE file in the project directory. ... ok Should have a README.md file in the project directory. ... ok culture result: ok. 2 passed. 0 failed. 0 undetermined.
测试
《cargo-culture》测试是通过标准的Rust集成测试框架进行管理的,并通过proptest属性测试库进行增强。
构建
构建但不运行测试
cargo build --tests
运行
构建和运行测试
cargo test
许可证
© 2018,PolySync Technologies,Inc。
- Zack Pierce 电子邮件
请参阅LICENSE文件以获取更多信息
依赖项
~4–14MB
~154K SLoC