added files flag fixes: #19

This commit is contained in:
Aaronepower 2015-11-26 22:32:13 +00:00
parent 5016096a35
commit 5a2ed87863
5 changed files with 29 additions and 24 deletions

View file

@ -1,2 +0,0 @@
service_name: travis-pro
repo_token: Uzeirjf6vl5nxzElBWG5afMSbeznLZk5c

View file

@ -10,10 +10,4 @@ matrix:
allow_failure:
- rust: nightly
sudo: false
deploy:
provider: releases
api_key:
secure: ifJz3iZaFhy0zaCNyTZ93nc48BiCunC/O8MTre+rZXIPjfyNUJVhBL8l+T76jd6GYMrEdDCl0dJawhLt8ARoTuRJ9aIzncc6NVztRzZhzfPxF0GkhsoosOnNrsIwMAi6Js+oYsT2ziQixjG3J6IvS1dcajEPIEaEbRaD582h4UUdkuNQZGQDo/BmmidyU2Dhi7wSeL0CFAWu/0hGuWZ7ycZlJme1JU9N+sRFlyVVHfP4BloNDDNdKDJkMgIJZI3wRCV4E9nMVQm8B8pkSIh7Sm42HfPTBjqhzujzRrN90+m86Leql8mNBlZBOQ98/rqe4w2G9lpP/YV6bvexUNM52IDpXlpvQt0S6g5nLNAPmZZ0VzQIGI5PVt0cDi9ryRfGwTgC0xiwlx3W0k7+I7bwxugQKz1fdMz4mqdruqazYo2Ry3tJizqZr4i4EK/ky/bCxNAQD4u9EPWU2VZcOK39FGKtVugkoSrW+b8sLjg64WK+Jx8awoJ4nVuIkCn3WSSpE6RuD0bFEG+BzRNvzaWwX0R9Zfr/XpG3CKJhnzATAJaTX/4xCJpIPppb2QrmcCSCGk34K7q1U+aevz1iVyiEteBkMHlZX7V78jhzRfq0/2yiijBA1f2rBYpGN/pcfSIVSxyco+smEKesq93SA62JrVOZqG/hgMHr5VafQL83pxo=
file: target/release/tokei
on:
repo: Aaronepower/tokei

View file

@ -25,6 +25,11 @@ args:
help: The input file(s)/directory(ies)
conflicts_with:
- languages
- files:
short: f
long: files
takes_value: false
help: Will print out the files found only recommended for debugging purposes
- languages:
short: l
long: languages

View file

@ -52,7 +52,6 @@ pub fn contains_comments(file: &str, comment: &str) -> bool {
pub fn get_all_files(path: String, ignored_directories: &[String]) -> Vec<String> {
let mut files: Vec<String> = Vec::new();
let mut dirs: Vec<String> = Vec::new();
if let Ok(result) = metadata(&path) {
if result.is_dir() {
@ -67,13 +66,16 @@ pub fn get_all_files(path: String, ignored_directories: &[String]) -> Vec<String
let file_string = file_str.to_owned();
let path_metadata = unwrap_rs_cont!(metadata(file_str));
if path_metadata.is_dir() {
for ignored_directory in ignored_directories {
if file_str.contains(ignored_directory) {
continue 'file;
}
for ignored_directory in ignored_directories {
if file_str.contains(ignored_directory) {
continue 'file;
}
}
if path_metadata.is_dir() {
for file in get_all_files(file_string, ignored_directories) {
files.push(file);
}
dirs.push(file_string);
} else if path_metadata.is_file() {
files.push(file_string);
}
@ -89,11 +91,6 @@ pub fn get_all_files(path: String, ignored_directories: &[String]) -> Vec<String
files.push(file_path);
}
}
for dir in dirs {
for file in get_all_files(dir, ignored_directories) {
files.push(file);
}
}
files
}

View file

@ -27,6 +27,7 @@ fn main() {
let yaml = load_yaml!("../cli.yml");
let matches = App::from_yaml(yaml).get_matches();
// Big list of languages
let action_script = RefCell::new(Language::new_c("ActionScript"));
let bash = RefCell::new(Language::new_single("BASH", "#"));
let batch = RefCell::new(Language::new_single("Batch", "REM"));
@ -48,7 +49,7 @@ fn main() {
let go = RefCell::new(Language::new_c("Go"));
let haskell = RefCell::new(Language::new_single("Haskell", "--"));
let html = RefCell::new(Language::new_html("HTML"));
let jai = RefCell::new(Language::new_c("JAI"));
let jai = RefCell::new(Language::new_c("JAI"));
let java = RefCell::new(Language::new_c("Java"));
let java_script = RefCell::new(Language::new_c("JavaScript"));
let julia = RefCell::new(Language::new("Julia", "#", "#=", "=#"));
@ -75,6 +76,8 @@ fn main() {
let xml = RefCell::new(Language::new_html("XML"));
let yaml = RefCell::new(Language::new_single("YAML", "#"));
// Languages are placed inside a BTreeMap, in order to print alphabetically
// by default
let mut languages: BTreeMap<&str, &RefCell<Language>> = BTreeMap::new();
languages.insert("as", &action_script);
languages.insert("bat", &batch);
@ -148,6 +151,7 @@ fn main() {
languages.insert("yaml", &yaml);
languages.insert("yml", &yaml);
// Print every supported language.
if matches.is_present("languages") {
for (_, language) in &languages {
let mut language = language.borrow_mut();
@ -162,7 +166,6 @@ fn main() {
let paths = matches.values_of("input").unwrap();
let mut ignored_directories: Vec<String> = Vec::new();
if let Some(user_ignored) = matches.value_of("exclude") {
for ignored in user_ignored.split(",") {
ignored_directories.push(ignored.to_owned());
@ -188,7 +191,7 @@ fn main() {
"Comments",
"Code");
println!("{}", ROW);
// Get every path from the paths provided.
for path in paths {
let files = get_all_files(path.to_owned(), &ignored_directories);
for file in files {
@ -202,6 +205,7 @@ fn main() {
let mut total = Language::new_blank("Total");
for (_, language) in &mut languages {
if language.borrow().printed {
continue;
}
@ -263,6 +267,13 @@ fn main() {
language.borrow_mut().printed = true;
if sort_empty {
println!("{}", *language.borrow());
if matches.is_present("files") {
println!("{}", ROW);
for file in &language.borrow().files {
println!("{}", file);
}
println!("{}", ROW);
}
}
}