cgag / loc

Count lines of code quickly.
MIT License
2.31k stars 125 forks source link

Use list file #60

Closed Jake-Shadle closed 7 years ago

Jake-Shadle commented 7 years ago

Sometimes it is more convenient to preprocess a list of files to remove complicated patterns that are annoying or impossible to specify via the --include --exclude regexes as well as use different sources for which files are interesting (eg. running a Powershell script to retrieve all of the files in a VS solution).

This PR adds support for letting you pass a file path via -l, --list-file which should just contain a path per line that will be used instead of the normal target argument to fill out the list of files to count.

cgag commented 7 years ago

sorry i've been really falling behind on issues/PRs for this

I'll look at the PR more later, but I think you can achieve the same thing by doing loc $(cat my-file-list)

Jake-Shadle commented 7 years ago

No problem!

While the cat option is obviously simple and doesn't require changes to loc itself, it assumes one is on an OS that has it, and has a way to expand the contents as arguments to loc, which isn't the case on Windows, at least easily.

Jake-Shadle commented 7 years ago

Realized that this was still open and you are right, doesn't make sense to add this when there are other ways to do it (cat is available in Windows with a standard git install anyway)

mvaled commented 10 months ago

@cgag

The $(cat ...) can run into trouble for very large list of files:

$ loc -- $(git ls-tree -r HEAD --name-only)
zsh: argument list too long: loc

So, passing a file like in:

$ loc --list-file=<(git ls-tree -r HEAD --name-only)

would be a nice addition.