Crates.io | xloc |
lib.rs | xloc |
version | 0.2.0 |
source | src |
created_at | 2021-11-07 21:00:15.384994 |
updated_at | 2021-11-15 04:00:23.262934 |
description | A fast, multi-threaded line counting utility written in Rust. |
homepage | https://github.com/Jonxslays/xloc |
repository | https://github.com/Jonxslays/xloc |
max_upload_size | |
id | 478230 |
size | 25,947 |
A fast, multi-threaded line counting utility written in Rust.
Similar to bash's wc
command, but can run concurrently.
Your project has x lines of code, xloc gets the value of x for you.
xloc is itended to be used from the command line. You can use it to count the number of lines/words in a file, or aggregate the total number of lines/words of all files in a directory.
While command line utility was the focus, a public API has also been
made available to use in your own rust projects in the form of
xloc::App
.
By default xloc will ignore any
directory named target
or .git
. This will likely be configurable
at a later date.
xloc supports Rust version 1.41.1 and greater.
For more information, read the API Reference.
cargo install xloc
# Cargo.toml
[dependencies]
xloc = "^0.2"
# Count lines for all files in the current dir, with 1 job.
xloc .
# Count words for all files in the current dir with nproc jobs.
xloc -wj $(nproc) .
# Count words for 1 file, with 1 job.
xloc -w test.txt
# Count lines for all files in the src dir, with 6 jobs.
xloc -j 6 src
// main.rs
use xloc::App;
fn main() {
// Create a mutable `App` using 1 job.
let mut app = App::default();
assert_eq!(app.get_njobs(), 1);
// Set the number of jobs to 12.
app.set_njobs(12);
assert_eq!(app.get_njobs(), 12);
// Recursively count lines in the current dir.
match app.count(".") {
Ok(count) => println!("{} lines", count),
Err(e) => println!("Error: {}", e),
}
}
The xloc crate for Rust is licensed under the BSD 3-Clause License.