CLOC is a tool for counting lines of source code information that can count blank, comment, and physical lines of source code in many programming languages. Given two versions of the codebase, the cloc can calculate the difference between blank lines, comment lines, and source code lines. It is written entirely in Perl and does not depend on standard distributions of Perl v5.6 and above (code from some external modules is embedded in the cloc), making it very portable. As we all know, cloc runs on a wide variety of Linux, FreeBSD, NetBSD, OpenBSD, macOS, AIX, HP-UX, Solaris, IRIX, z/OS, and Windows. (To run the Perl source version of the cloc on Windows, you need ActiveState Perl 5.6.1 or later, Strawberry Perl, Windows Subsystem for Linux, Cygwin, MobaXTerm, or the mingw environment and terminal, such as those provided by Git for Windows.) Alternatively, the Windows binary of the cloc generated using PAR::P acker can be used to run on a Windows computer that has neither Perl nor Cygwin. )
GitHub address:The hyperlink login is visible. Download Address:The hyperlink login is visible.
Install via the package manager
npm install -g cloc #The hyperlink login is visible. sudo apt install cloc # Debian, Ubuntu sudo yum install cloc # Red Hat, Fedora sudo dnf install cloc # Fedora 22 or later sudo pacman -S cloc # Arch sudo emerge -av dev-util/cloc # GentooThe hyperlink login is visible. sudo apk add cloc # Alpine Linux doas pkg_add cloc # OpenBSD sudo pkg install cloc # FreeBSD sudo port install cloc # macOS with MacPorts brew install cloc # macOS with Homebrew choco install cloc # Windows with Chocolatey scoop install cloc # Windows with Scoop You can add a cloc to an environment variable, refer to the tutorial below:
Count the amount of code in the current folder
Exclude the amount of code for a folder
Count the number of lines of code for each file in the directory
Parameter options
--diff <set1> <set2> - calculates the code difference between the source files of set1 and set2. The input can be a mix of files and directories. --git - force inputs to be recognized as git targets if they are not recognized as file or directory names in the first place. --ignore-whitespace - ignores horizontal spaces when comparing files with --diff. --max-file-size=<MB> - if you want to skip files larger than a given amount of MB. --exclude-dir=<dir1>,<dir2> - exclude a given comma-separated directory. --exclude-ext=<ext1>,<ext2> - Exclude the given file extension. --csv - Export the results to CSV file format. --csv-delimiter=<C> - uses <C>characters as delimiters. --out=<file> - Save the result to<file> . --quiet - disables all informational messages and only shows the final report. --sql=<file> - Writes the result as create and insert statements, which can be read by a database program such as SQLite.
(End)
|