tokei icon indicating copy to clipboard operation
tokei copied to clipboard

Proposal: Support ignore all subdirectories by a single option.

Open And-ZJ opened this issue 1 year ago • 3 comments

Hello, thanks for the tools. So far I've found that, by default, when you supply a directory, the tool counts the code in that directory and all its subdirectories. But sometimes, I just want to count the current directory, not the subdirectories. I took a quick look and there doesn't seem to be a single such option. If the --exclude parameter is used, it is troublesome when there are many subdirectories. I wish it could provide an option to ignore all subdirectories. Thank you!

And-ZJ avatar Feb 12 '25 03:02 And-ZJ

If the maintainers are in support of this, I am willing to try my hand at implementing this.

JackDyre avatar Feb 18 '25 03:02 JackDyre

An approach mentioned back in #676 was that we could support a wider range of use cases by allowing Tokei to optionally take a file list from stdin, which would then let it be piped into with find. Taking the proposed syntax from there, traversing a directory for files non-recursively would be done with something like find . -maxdepth 1 -type f | tokei -.

Swiddis avatar Feb 19 '25 20:02 Swiddis

Thank you! Yes, find . -maxdepth 1 -type f | tokei - is a good way to do it.

However, I actually wrote a piece of Go code to invoke this tool. This way of writing increases the complexity of writing code. That's why I had this idea. I hope you'll think about it again. Thank you.

And-ZJ avatar Feb 20 '25 03:02 And-ZJ