cgag / loc

Count lines of code quickly.
MIT License
2.29k stars 126 forks source link

Count lines in files of arbitrary extensions #122

Open alanhogan opened 4 years ago

alanhogan commented 4 years ago

I’d like for loc to take an option that allows counting of any arbitrary file extension(s). It could ignore blank lines without knowing the specific syntax.

Perhaps a few generic formats could be defined, such as "pound-commented" and "C-like". The former would recognize # this style of comment; the latter could ignore lines with only } end brackets (I’m not sure if LOC already does this for C, JS, etc) and would recognize /* this */ and // this style of comments.

Alternatively, extensions could be treated as other existing languages; I might alias .hdbs to .html.

From a purely utilitarian point of view, counting lines in unknown formats is still useful even if the comments can not be identified.

I’m personally curious to see .hdbs (handlebars) statistics, but this issue could resolve (or nearly resolve) many other specific requests: #113, #109, #100, #101, #102, and so on.

Example syntax might be:

loc my_folder/ --include-extensions=hdbs
loc --include-extensions=hdbs --parse-as=hdbs,html
loc --include-extensions=hdbs,pyw --parse-as=hdbs,html,pyw,py
loc --include-extensions=acme-config --parse-as=acme-config,pound-commented