Categorygithub.com/Scorpio69t/gcloc
repositorypackage
1.0.4
Repository: https://github.com/scorpio69t/gcloc.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

gcloc: Source Code Line Counter

中文 | English

gcloc is an open-source tool designed to count source code files and lines in various programming languages. It supports a wide range of languages and is easily extendable to include custom languages. Simple and easy to use, gcloc helps developers quickly understand their codebase and track changes over time.


Acknowledgment

This project builds upon the foundational work of hhatto's gocloc. We sincerely thank the original author for their contributions to the open-source community, which provided the basis for gcloc's further development.


Features

  • Language Support: Counts files, blank lines, comment lines, and code lines for multiple programming languages.
  • Customizable: Add support for more languages as needed.
  • High Performance: Utilizes concurrency for efficient file retrieval and analysis, making it fast even for large codebases.
  • Output Formats: Supports multiple output formats, including default table view, XML, JSON, and Sloccount format.
  • Filters: Include or exclude files and directories based on extensions, regex patterns, or specific languages.
  • Detailed Statistics: Optionally report results for each source file.

Future Development

  • Support for Git Repositories

    • Analyze Git repositories directly without specifying a directory.
    • Display statistics for the entire repository, including commit history.
  • Web Interface

    • Create a web interface for gcloc to provide a user-friendly experience.
    • Allow users to upload files or directories for analysis.
  • Support for Archive Files

    • Analyze compressed files (e.g., .zip, .tar.gz) without manual extraction.
    • Extract and analyze files on-the-fly to provide accurate statistics.

Installation

go install github.com/Scorpio69t/gcloc/app/gcloc@latest

Alternatively, download the precompiled binary from the Releases page.


Usage

gcloc [flags] PATH...
gcloc [command]

Example

Analyze the current directory:

gcloc .

Sample Output:

$gcloc .
github.com/Scorpio69t/gcloc T=0.03 s (7318.7 files/s 2219353.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C++ Header                       8           9494           3756          37956
C++                             28           3137           1752          13517
JSON                            43              1              0           9368
...
Total                          249          14710           7060          75508
-------------------------------------------------------------------------------

Commands

General Commands

  • completion: Generate the autocompletion script for your shell.
  • help: Display help information for a command.
  • show-lang: List all supported languages and their extensions.
  • version: Print the version number of gcloc.

Flags

FlagDescription
--by-fileReport results for every encountered source file.
--debugDump debug log for developers.
--exclude-extExclude file name extensions (comma-separated).
--exclude-langExclude specific languages (comma-separated).
--include-langInclude specific languages (comma-separated).
--matchInclude files matching a regex pattern.
--not-matchExclude files matching a regex pattern.
--match-dInclude directories matching a regex pattern.
--not-match-dExclude directories matching a regex pattern.
--output-typeChoose an output format: default, gcloc-xml, sloccount, json (default: default).
--skip-duplicatedSkip duplicated files.
--sortSort results by name, files, blanks, comments, or codes (default: codes).

Examples

Analyze Specific Directory

gcloc /path/to/code

Include Only Specific Languages

gcloc --include-lang "C++,JSON" .

Exclude Files by Extension

gcloc --exclude-ext "json,xml" .

Generate JSON Output

gcloc --output-type json .

Show Supported Languages

gcloc show-lang

Contribution

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with detailed explanations.

License

This project is licensed under the MIT License.


Acknowledgments

Special thanks to all contributors who helped make gcloc a robust and reliable tool for source code analysis.