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

Add --directories to allow for outputting summaries per directory #426

Open
svenstaro opened this issue Jan 9, 2020 · 5 comments
Open

Comments

@svenstaro
Copy link
Contributor

Currently we have --files which allows for outputting line counts per files but I'd like it per top level directory. Imagine tokei --directories * which would output summaries for lines for each provided directory.

@XAMPPRocky
Copy link
Owner

Thank you for issue! I remember when I implemented --files I thought about whether there should be a --directories option, and my initial thought was that output isn't likely to be intuitive for deeply nested directory structures. I'll look into implementing this feature over the next couple of weeks.

@svenstaro
Copy link
Contributor Author

That's why I thought it's perhaps a good idea to just implement it for exactly the directory you provide as arguments. So essentially a sum per dir. I don't thinking showing the dirs recursively will serve well but they should of course be traversed for the line counts themselves.

@lnicola
Copy link

lnicola commented Jun 14, 2020

I just came here to ask for the same feature, I think. Showing the counts for the top-level directories would work for me. My workaround is for p in ./*; do echo $p; tokei "$p"; done.

@matklad
Copy link
Contributor

matklad commented Aug 31, 2021

👋 @lnicola :-)

One specific use-case for this feature -- in rust-analyzer, I want to run cargo vendor and then look at the largest (in terms of loc) deps.

@xmo-odoo
Copy link

Thank you for issue! I remember when I implemented --files I thought about whether there should be a --directories option, and my initial thought was that output isn't likely to be intuitive for deeply nested directory structures. I'll look into implementing this feature over the next couple of weeks.

I think the idea was rather more something like du --summarize: show a result for each input (each path passed explicitly to tokei) rather than each directory it encounters during its traversal.

That would be very tremendously useful to compare or collate multiple directories. The one difficulty would be what happens when providing overlapping paths (e.g. tokei ./foo ./bar .). For that case du -s will only report on the bits of . which are not part of the preceding targets, but I don't know whether it would be more useful for tokei to do that or to show the "full" summation (as if three separate invocations).

My gut feeling would be that a du-like behaviour would be the most useful to answer questions like "what's the code distribution betwenn ./foo, ./bar and the rest", but I would think that's also a lot more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants