Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) Standard preamble: ========================================================================
NAMEcloc - Count, and compute differences of, lines of source code and comments.
cloc [options] <FILE|DIR> ...
DESCRIPTIONCount, or compute differences of, physical lines of source code in the given files (may be archives such as compressed tarballs or zip files) and/or recursively below the given directories. It is written entirely in Perl, using only modules from the standard distribution.
Input OptionsTo count standard input, use the special filename - and either --stdin-name=FILE to tell cloc the name of the file being piped in, or --force-lang=LANG to apply the
This option is only needed if cloc is unable to figure out how to
extract the contents of the input file(s) by itself. Use CMDto extract binary archive files (e.g.: .tar.gz, .zip, .Z). Use the literal '>FILE<' as a stand-in for the actual file(s) to be extracted. For example, to count lines of code in the input files gcc-4.2.tar.gz perl-5.8.8.tar.gz on Unix use:
--extract-with='gzip -dc >FILE< | tar xf -
or, if you haveGNUtar:
--extract-with='tar zxf >FILE<'
and on Windows, use, for example:
--extract-with="\"c:\Program Files\WinZip\WinZip32.exe\" -e -o >FILE<
Take the list of file and/or directory names to
process from FILE,which has one file/directory name per line. Only exact matches are counted; relative path names will be resolved starting from the directory where cloc is invoked. See also --exclude-list-file
Invoke a system call to VCSto obtain a list of files to work on. IfVCSis 'git', then will invoke 'git ls-files'. IfVCSis 'svn' then will invoke 'svn list -R'. The primary benefit is that cloc will then skip files explicitly excluded by the versioning tool in question, ie, those in .gitignore or have the svn:ignore property. AlternativelyVCSmay be any system command that generates a list of files. Note: cloc must be in a directory which can read the files as they are returned byVCS.cloc will not download files from remote repositories. 'svn list -R' may refer to a remote repository to obtain file names (and therefore may require authentication to the remote repository), but the files themselves must be local.
Check binary files to see if they contain Unicode expanded ASCIItext. This causes performance to drop noticeably.
Count .in files (as processed by GNUautoconf) of recognized languages.
- Report results for every source file encountered.
- Report results for every source file encountered in addition to reporting by language.
- --count-and-diff SET1 SET2
First perform direct code counts of source file(s)
of SET1andSET2separately, then perform a diff of these. Inputs may be pairs of files, directories, or archives. See also --diff, --diff-alignment, --diff-timeout, --ignore-case, --ignore-whitespace.
- --diff SET1 SET2
Compute differences in code and comments between source file(s) of
SET1andSET2.The inputs may be pairs of files, directories, or archives. Use --diff-alignment to generate a list showing which file pairs where compared. See also --count-and-diff, --diff-alignment, --diff-timeout, --ignore-case, --ignore-whitespace.
- --diff-timeout N
- Ignore files which take more than N seconds to process. Default is 10 seconds. (Large files with many repeated lines can cause Algorithm::Diff::sdiff() to take hours.)
- [Unix only] Follow symbolic links to directories (sym links to files are always followed).
Process all files that have a EXTextension with the counter for languageLANG.For example, to count all .f files with the Fortran 90 counter (which expects files to end with .f90) instead of the default Fortran 77 counter, use:
IfEXTis omitted, every file will be counted with theLANGcounter. This option can be specified multiple times (but that is only useful whenEXTis given each time). See also --script-lang, --lang-no-ext.
Load language processing filters from FILE,then use these filters instead of the built-in filters. Note: languages which map to the same file extension (for example: MATLAB/Objective C/MUMPS; Pascal/PHP; Lisp/OpenCL; Lisp/Julia; Perl/Prolog) will be ignored as these require additional processing that is not expressed in language definition files. Use --read-lang-def to define new language filters without replacing built-in filters (see also --write-lang-def).
- Ignore horizontal white space when comparing files with --diff. See also --ignore-case.
- Ignore changes in case; consider upper- and lowercase letters equivalent when comparing files with --diff. See also --ignore-whitespace.
Count files without extensions using the LANGcounter. This option overrides internal logic for files without extensions (where such files are checked against known scripting languages by examining the first line for "#!"). See also --force-lang, --script-lang.
Skip files larger than "MB" megabytes when
traversing directories. By default, "MB"=100.
cloc's memory requirement is roughly twenty times
larger than the largest file so running with
files larger than 100 MBon a computer with less than 2GBof memory will cause problems. Note: this check does not apply to files explicitly passed as command line arguments.
- Process binary files in addition to text files. This is usually a bad idea and should only be attempted with text files that have embedded binary data.
Load new language processing filters from FILEand merge them with those already known to cloc. IfFILEdefines a language cloc already knows about, cloc's definition will take precedence. Use --force-lang-def to over-ride cloc's definitions. (see also --write-lang-def).
Process all files that invoke "S" as a "#!" scripting language with the
counter for language LANG.For example, files that begin with "#!/usr/local/bin/perl5.8.8" will be counted with the Perl counter by using
The language name is case insensitive but the name of the script language executable, "S", must have the right case. This option can be specified multiple times. See also --force-lang.
Use DIRas the scratch directory instead of letting File::Temp chose the location. Files written to this location are not removed at the end of the run (as they are with File::Temp).
- Skip the file uniqueness check. This will give a performance boost at the expense of counting files with identical contents multiple times (if such duplicates exist).
Count lines streamed via STDINas if they came from a file namedFILE.
- For each file processed, write to the current directory a version of the file which has blank lines and comments removed. The name of each stripped file is the original file name with ".EXT" appended to it. It is written to the current directory unless --original-dir is on.
- Write the stripped files the same directory as the original files. Only effective in combination with --strip-comments.
- Input arguments are report files previously created with the --report-file option. Makes a cumulative set of results containing the sum of data from the individual report files.
Over-ride the operating system detection logic and run in UNIXmode. See also --windows, --show-os.
- If SLOCCount is installed, use its compiled executables c_count, java_count, pascal_count, php_count, and xml_count instead of cloc's counters. SLOCCount's compiled counters are substantially faster than cloc's and may give a performance improvement when counting projects with large files. However, these cloc-specific features will not be available: --diff, --count-and-diff, --strip-comments, --unicode.
- Over-ride the operating system detection logic and run in Microsoft Windows mode. See also --unix, --show-os.
- --exclude-dir=DIR1[,DIR2 ...]
Exclude the given comma separated directories from being scanned. For
will skip all files that match "/.cache/" or "/test/" as part of their path. Directories named ".bzr", ".cvs", ".hg", ".git", and ".svn" are always excluded.
- --exclude-ext=EXT1[,EXT2 ...]
- Do not count files having the given file name extensions.
- --exclude-lang=L1[,L2 ...]
- Exclude the given comma separated languages from being counted.
- --exclude-list-file=FILE Ignore files and/or directories whose names appear in FILE. FILEshould have one file name per line. Only exact matches are ignored; relative path names will be resolved starting from the directory where cloc is invoked. See also --list-file.
- --fullpath Modifies the behavior of --match-f or --not-match-f to include the file's path in the regex, not just the file's basename. (This does not expand each file to include its absolute path, instead it uses as much of the path as is passed in to cloc.)
- --include-lang=L1[,L2 ...]
- Count only the given comma separated languages L1, L2, L3, et cetera.
Only count files in directories matching the Perl regex. For example
only counts files in directory paths containing "/src/" or "/include/".
- Count all files except in directories matching the Perl regex.
Only count files whose basenames match the Perl regex. For example
this only counts files at start with Widget or widget:
- Count all files except those whose basenames match the Perl regex.
Ignore files that end with the given Perl regular
expression. For example, if given
--skip-archive='(zip|tar(\.(gz|Z|bz2|xz|7z))?)' the code will skip files that end with .zip, .tar, .tar.gz, .tar.Z, .tar.bz2, .tar.xz, and .tar.7z.
- On Windows, ignore hidden files.
Save names of categorized files to FILE.
Save names of processed source files to FILE.
Write to FILEa list of files and file pairs showing which files were added, removed, and/or compared during a run with --diff. This switch forces the --diff mode on.
Print the filters used to remove comments for
language LANGand exit. In some cases the filters refer to Perl subroutines rather than regular expressions. An examination of the source code may be needed for further explanation.
- Print this usage information and exit.
Save names of every file found to FILE.
Save names of ignored files and the reason they were ignored to FILE.
Print to STDOUTprocessed source code before and after each filter is applied.
- Print information about all known (or just the given) file extensions and exit.
- Print information about all known (or just the given) languages and exit.
- Print the value of the operating system mode and exit. See also --unix, --windows.
- Turn on verbose with optional numeric value.
- Long form of -v.
- Print the version of this program and exit.
Writes to FILEthe language processing filters then exits. Useful as a first step to creating custom language definitions. See also --force-lang-def, --read-lang-def.
- Print third-generation language output. (This option can cause report summation to fail if some reports were produced with this option while others were produced without it.)
- --by-percent X
Instead of comment and blank line counts, show
these values as percentages based on the
value of X in the denominator:
X = 'c' -> # lines of code X = 'cm' -> # lines of code + comments X = 'cb' -> # lines of code + blanks X = 'cmb' -> # lines of code + comments + blanks
For example, if using method 'c' and your code has twice as many lines of comments as lines of code, the value in the comment column will be 200%. The code column remains a line count.
- Write the results as comma separated values.
- Use the character C as the delimiter for comma separated files instead of ,. This switch forces --csv to be on.
- Write the results as Markdown-formatted text.
- Synonym for --report-file=FILE.
Show progress update after every N files are processed (default
N=100). Set N to 0 to suppress progress output; useful when
redirecting output to STDOUT.
- Suppress all information messages except for the final report.
Write the results to FILEinstead of standard output.
Write results as SQL CREATEandINSERTstatements which can be read by a database program such as SQLite. IfFILEis -, output is sent toSTDOUT.
Append SQLinsert statements to the file specified by --sql and do not generate table creation option.
- Use <name> as the project identifier for the current run. Only valid with the --sql option.
Write SQLstatements in the given style instead of the default SQLite format. Currently, the only style option is Oracle.
For plain text reports, show the SUM:output line even if only one input file is processed.
Write the results in XML.
Reference FILEas anXSLstylesheet within theXMLoutput. IfFILEis not given, writes a default stylesheet, cloc.xsl. This switch forces --xml to be on.
Write the results in YAML.
EXAMPLESCount the lines of code in the Perl 5.10.0 compressed tar file on a UNIX-like operating system:
Count the changes in files, code, and comments between Python releases 2.6.6 and 2.7:
cloc --diff Python-2.6.6.tar.bz Python-2.7.tar.bz2
To see how cloc aligns files for comparison between two code bases, use the --diff-alignment=FILE option. Here the alignment information is written to "align.txt":
cloc --diff-aligment=align.txt gcc-4.4.0.tar.bz2 gcc-4.5.0.tar.bz2
Print the recognized languages
Remove comments from "foo.c" and save the result in "foo.c.nc"
cloc --strip-comments=nc foo.c
Additional examples can be found at <cloc.sourceforge.net>.
AUTHORSThe cloc program was written by Al Danial <firstname.lastname@example.org> and is Copyright (C) 2006-2016 <email@example.com>.
The manual page was originally written by Jari Aalto <firstname.lastname@example.org>.
Both the code and documentation is released under the