| Crates.io | file-identify |
| lib.rs | file-identify |
| version | 0.2.0 |
| created_at | 2025-08-07 20:22:50.676633+00 |
| updated_at | 2025-08-07 23:08:48.089839+00 |
| description | File identification library for Rust - detects file types based on extensions, shebangs, and content |
| homepage | |
| repository | https://github.com/grok-rs/file-identify |
| max_upload_size | |
| id | 1785769 |
| size | 130,602 |
File identification library for Rust.
Given a file (or some information about a file), return a set of standardized tags identifying what the file is.
This is a Rust port of the Python identify library.
Add this to your Cargo.toml:
[dependencies]
file-identify = "0.2.0"
use file_identify::{tags_from_path, tags_from_filename, tags_from_interpreter};
// Identify a file from its path
let tags = tags_from_path("/path/to/file.py").unwrap();
println!("{:?}", tags); // {"file", "text", "python", "non-executable"}
// Identify from filename only
let tags = tags_from_filename("script.sh");
println!("{:?}", tags); // {"text", "shell", "bash"}
// Identify from interpreter
let tags = tags_from_interpreter("python3");
println!("{:?}", tags); // {"python", "python3"}
# Install the CLI tool
cargo install file-identify
# Identify a file
file-identify setup.py
["file", "non-executable", "python", "text"]
# Use filename only (don't read file contents)
file-identify --filename-only setup.py
["python", "text"]
# Get help
file-identify --help
A call to tags_from_path does this:
By design, this means we don't need to partially read files where we recognize the file extension.
# Clone the repository
git clone git@github.com:grok-rs/file-identify.git
cd file-identify
# Build the project
cargo build
# Run tests
cargo test
# Run the CLI
cargo run -- path/to/file
This project uses pre-commit hooks to ensure code quality:
pip install pre-commit
pre-commit install
# Run all tests
cargo test
# Run with coverage (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --out html
To create a new release:
Cargo.tomlCHANGELOG.md with new version notesgit commit -am "Bump version to x.y.z"git tag vx.y.z && git push origin vx.y.zThe release workflow will automatically:
RELEASE_TOKEN secretMIT