The Code Line Counter is a script that counts the lines of code in a project. It provides the flexibility to exclude specific paths and file extensions from the line count.
- Counts the lines of code in your project.
- Allows excluding specific paths and file extensions from the line count.
- Supports various programming languages and file types.
- Ensure you have Python installed on your system (version 3 or above).
- Clone this repository or download the
count_lines.py
script. - Open a terminal or command prompt and navigate to the directory where the script is located.
- Run the script using the following command:
python count_lines.py [project_directory] [-e EXCLUDE_FOLDERS...] [-i IGNORE_EXTENSIONS...] [-f IGNORE_FILES [IGNORE_FILES ...]]
- Replace
[project_directory]
with the path to your project directory. - Use the optional
-e
or--exclude
flag followed by one or more folder names to exclude specific folders from the line count. - Use the optional
-i
or--ignore
flag followed by one or more file extensions to ignore specific file extensions during the line count. - Use the optional
-f
or--ignore-files
flag followed by one or more file names to ignore specific files from the line count.
- The script will display the total lines of code in the project, excluding the specified folders and file extensions.
- Python 3.x
The script can optionally utilize the tqdm
package to display a progress bar during the line counting process. If the tqdm
package is installed, the progress bar will be displayed. If it is not installed, a simple print statement will be used instead.
To install the tqdm
package, use the following command:
pip install tqdm
If you don't wish to use the progress bar or prefer not to install the tqdm
package, you can still run the script without any issues.
- Count the lines of code in a project directory:
python count_lines.py /path/to/your/project
- Count lines of code in a project, excluding the
tests
anddocs
folders:
python count_lines.py /path/to/your/project -e tests docs
- Count lines of code in a project, excluding the
tests
folder and ignoring.txt
and.log
file extensions:
python count_lines.py /path/to/your/project -e tests -i .txt .log
- Count the lines of code while excluding specific folders, file extensions, and files:
python count_lines.py /path/to/project -e vendor var .git .idea -i .txt -f *.dist.php *.log
- The script currently supports counting lines of code for files encoded in UTF-8.
This script is licensed under the MIT License.