5 个不稳定版本
0.3.1 | 2024 年 4 月 26 日 |
---|---|
0.3.0 | 2024 年 3 月 27 日 |
0.2.1 | 2024 年 2 月 13 日 |
0.2.0 | 2023 年 3 月 11 日 |
0.1.0 | 2023 年 3 月 11 日 |
#90 在 Cargo 插件 中
334 每月下载量
23KB
379 代码行
cargo-files
列出 cargo 包中所有源文件的工具。
动机
在我编写 cargo-derivefmt 的过程中,我希望有一个简单的方法来获取 cargo 包中的源文件。我没有找到现有的包来做这件事,所以我就写了这个。
这个库仍在开发中。可能存在许多问题和不受支持的情况。
命令行界面 (CLI)
对于最终用户,我们提供了一个 CLI,它将列出包中的所有源文件。
安装
cargo install
(crates.io)
cargo install cargo-files --locked
cargo install
(master)
cargo install --git https://github.com/dcchut/cargo-files --locked
用法
cargo files
示例输出
> cargo files
/home/dcchut/cargo-files/cargo-files/src/main.rs
/home/dcchut/cargo-files/cargo-files-core/src/lib.rs
/home/dcchut/cargo-files/cargo-files-core/src/parser.rs
/home/dcchut/cargo-files/cargo-files-core/tests/tests.rs
/home/dcchut/cargo-files/cargo-files-test/src/lib.rs
开发者
cargo-files-core
包包含 cargo-files
的底层逻辑,并且可以被其他关心源文件的应用程序重用。目前 API 非常简单,任何改进建议都欢迎!
最小示例
use cargo_files_core::{get_targets, get_target_files, Error};
fn main() -> Result<(), Error> {
// Each target (e.g. bin/lib) in your workspace will contribute a target.
let targets = get_targets(None)?;
for target in targets {
// Get all the files related to a specific target.
let files = get_target_files(&target)?;
for file in files {
println!("{}", file.display());
}
}
Ok(())
}
依赖关系
~2–3MB
~56K SLoC