Crate tokei [−] [src]
Tokei: Code Analysis Library
A simple, effcient library for analysing code in directories.For the binary
How to use
Tokei provides both Languages
a map of existing programming languages and Language
for creating custom languages.
Example(Get total lines of code from all rust files in current directory, and all subdirectories)
extern crate tokei; use std::collections::BTreeMap; use std::fs::File; use std::io::Read; use tokei::{Languages, LanguageType}; fn main() { // The paths to search. Accepts absolute, relative, and glob paths. let paths = vec!["**/*.rs"]; // Exclude any path that contains any of these strings. let excluded = vec!["target", ".git"]; // Create new Languages let mut languages = Languages::new(); // Get statistics languages.get_statistics(&*paths, &*excluded); // Remove empty languages let language_map = languages.remove_empty(); // Get Rust from statistics let rust = language_map.get(&LanguageType::Rust).unwrap(); // Print the number of lines that were code. println!("Lines of code: {}", rust.code); }
Structs
Language | |
Languages |
A collection of existing languages(List of Languages) |
Stats |
A struct representing the statistics of a file. |
Enums
LanguageType | |
Sort |
Used for sorting languages. |