Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for filtering out subtree(s) when calculating stats #178

Closed
ricab opened this issue Jun 15, 2020 · 2 comments
Closed

Support for filtering out subtree(s) when calculating stats #178

ricab opened this issue Jun 15, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@ricab
Copy link

ricab commented Jun 15, 2020

Just want to suggest an addition to this very nice project. I would find it useful if onefetch had an option to filter out directories and/or files when calculating stats like Languages, LoC and Size.

I find that current results are quite skewed for projects that include many submodules or other code dependencies. An exclusion pattern would allow ignoring things like third-party code, documentation, examples, etc. I imagine something like --exclude <pattern>.

Alternatively (or additionally), there could be an option to discount git submodules. That would be easier to use, but less general.

@o2sh o2sh added the enhancement New feature or request label Jun 16, 2020
@o2sh
Copy link
Owner

o2sh commented Jun 16, 2020

Yes, the --exclude <pattern> flag would be a nice addition to the tool. tokei (used by onefetch to retrieve language statistics) already has this feature. So we "just" need to use it (from lib.rs):

// Exclude any path that contains any of these strings.
let excluded = &["target"];
let config = Config::default();
let mut languages = Languages::new();
languages.get_statistics(paths, excluded, &config);
let rust = &languages[&LanguageType::Rust];

Doing so, Languages and LoC sections will be updated based on the flag's input. However the Size will remain unchanged as it relies on a git command and not tokei.

@o2sh
Copy link
Owner

o2sh commented Jun 21, 2020

XAMPPRocky/tokei#564

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants