| Crates.io | cargo-files-core |
| lib.rs | cargo-files-core |
| version | 0.3.1 |
| created_at | 2023-03-11 02:51:32.583636+00 |
| updated_at | 2025-06-21 00:25:13.655529+00 |
| description | Core functionality for cargo-files |
| homepage | |
| repository | https://github.com/dcchut/cargo-files |
| max_upload_size | |
| id | 806909 |
| size | 48,459 |
A tool to list all source files in a cargo crate.
While I was writing cargo-derivefmt I found myself wishing for a simple way to get the source files in a cargo crate. I wasn't able to find an existing crate which did this, so I wrote this one.
This library is still a work-in-progress. There are likely many issues and unsupported situations.
For end users, we provide a CLI which lists all source files in a crate.
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
The cargo-files-core crate contains the logic underlying cargo-files, and can
be reused by other applications that care about source files. At the moment the API
is extremely simplistic, but any improvement suggestions are welcome!
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(())
}