How to count lines of code and compare the LOC difference in one command?

2.3k views Asked by At

I'm using cloc 1.60 .

I'm wondering if that's possible to run the following two commands in one "cloc" command?

> cloc-1.60.exe --diff file1 file2 # returns the difference

> cloc-1.60.exe file2  

I have to calculate the % of changed lines. I can do that by running these two commands. However I'd prefer to run them both in one command if possible.

Thank you

2

There are 2 answers

0
AlDanial On BEST ANSWER

there currently is not a way to run both a diff and a straight count with a single command. I'll consider that for a future release though. Would be helpful if you filed a feature request (http://sourceforge.net/p/cloc/feature-requests/?source=navbar) so I don't forget.

1
AlDanial On

I just committed a change that implements a new switch, --count-and-diff, that does the counts and diff in one shot. It will appear in the next release. Or you can use it now by working with the development version at https://sourceforge.net/p/cloc/code/HEAD/tree/trunk/cloc