One day our team has discussion about how to estimate amount of source code for one of our projects. First idea was just calculate total files size, but... A whole bunch of questions arised immediately: there are a lot of vendor code in project, there are binary files, there are images, generated code, multi-byte character encodings and so on.
Our goal was to understand just how many pure code was written by our team. And we want to know characters, lines and printed-pages estimate counts for projects. So this pet-project was born as an answer to this questions.
mt-howmany is composer based command-line utility. It is installed like any composer package as a dependency:
composer require mitoteam/mt-howmany
Please take a look at GitHub project page for more details about installation and program usage.
Both UNIX-based and Windows OS are supported. All paths are relative to working directory, directory separators are changed from UNIX-ones (/) to Windows-ones (\) automatically when needed.
Unicode strings are handled by symfony/string package for proper characters count calculation. Tool supports exclusions by file extension or by file type. You can define custom characters per page and lines per page values in config.
Config files are in YAML. There is an ability to split config file to several files (importing one to another). We use this to have common part of config in common repository and individual per-project configs.
Program output example for binardo project:
mt-howmany by MiTo Team
=======================
Working directory: /www/binardo.mt.test
Config file loaded: /www/binardo.mt.test/web/modules/custom/mtlapbase/mt-howmany.common.yml
Config file loaded: /www/binardo.mt.test/mt-howmany.yml
Results by file extension
=========================
----------- -------- ------------ ------------- -------
Type Size Characters Files Count Lines
----------- -------- ------------ ------------- -------
php 777Kb 782756 174 32225
twig 50.0Kb 51145 26 1471
scss 29.8Kb 30464 47 1886
js 17.1Kb 17276 11 637
yml 15.5Kb 15767 18 621
sh 9.59Kb 9816 11 348
po 3.69Kb 2965 1 164
json 3.27Kb 3344 4 127
module 3.10Kb 3176 2 131
theme 3.06Kb 3133 2 123
gitignore 2.23Kb 2280 2 82
md 2.08Kb 1323 6 38
txt 139 139 1 8
htaccess 38 38 2 4
----------- -------- ------------ ------------- -------
Totals
======
Types count: 14
Paths count: 67
Files count: 307
Size: 916Kb
Characters: 923622
Lines: 37865
Pages by Characters: 257
Pages by Lines: 1052
- Project Page: mt-howmany
- GitHub: