boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.48k stars 254 forks source link

Add thousands separators to numbers by default #52

Open skorokithakis opened 5 years ago

skorokithakis commented 5 years ago

Since the default output is meant to be human-readable, would it make sense to add thousands separators to make the output more easily readable?

boyter commented 5 years ago

I thought this request sounded familiar, and yep https://github.com/Aaronepower/tokei/issues/256 also in tokei.

There might be some complexity when dealing with larger projects as if the value is too large it would overflow, but at least could fall back to the existing logic.

The big catch with it is that it should account for regions https://en.wikipedia.org/wiki/Decimal_separator#Examples_of_use as different countries determine this differently. I had a quick look and I belive it should be possible to do using https://godoc.org/golang.org/x/text/message and https://godoc.org/golang.org/x/text/language

If implemented I belive this should probably not be on by default, but provide a -h flag similar to how du and ls work in order to ensure backwards compatibility, but I am open to debate about that. I would hope anyone using the default output is not attempting to parse it, but using JSON or CSV output. One case that comes to mind to check would be https://github.com/intel/nemu/blob/topic/virt-x86/tools/cloc-change.sh#L9 as they build from master each time.

skorokithakis commented 5 years ago

I would hope anyone using the default output is not attempting to parse it, but using JSON or CSV output

I would hope the same, and thus would think that it would be fine to turn this on by default, but you know how backwards compatibility goes, so the decision is up to you.