Proposal: add a --by-dir option
Author: arp242Created Feb 6, 2021Updated Jun 24, 2026
Labelsenhancement
I often find it useful to list code size by directory; use cases are:
- Knowing which parts of a codebase take up how many lines of code, e.g. "70% of the code is in the
foopackage". - The grand totals can give a skewed picture because it may include things like included libraries, tests, build infrastructure, and so forth that you probably want to exclude, and listing it by directory first is a convenient way to get this overview (aside: a
--testflag, similar to--genmight also make sense, especially for environments where tests aren't in separate directories, like Go, but that's a different issue).
Right now there's --by-file, but that's too fine-grained. So I propose to add a new flag:
--by-dir=n display output for every directory of at most n levels deep.The parameter works the same as -d for e.g. du; I could add a new --depth parameter, but I think just accepting a value here makes more sense.
I'll work on a patch, but I wanted to make an issue first to discus to prevent working on something that may not get merged.
Thanks!
Source: boyter/scc