Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kloc

(thousands of lines of code)

A tool that helps you know how many lines of code you have in your working directory.

Installation

Warning

I actually don't know how to make an installation script or put kloc on pypi and make it installable with pip. You may have to figure out adding to path and making it work as you want, etc.

  1. Prerequisites:

    • Python 3.6 or higher.
    • Install rich library: pip install rich
  2. Clone the repository (or download the files):

  3. git clone https://github.com/your-repo/kloc-python.git # (If this were a real repo)
    cd kloc-python

    For now, ensure kloc.py, kloc.config.json, .klocignore, and requirements.txt are in your desired project directory.

  4. Install dependencies:

    pip install -r requirements.txt

Usage

You can run the kloc.py script directly using Python.

General Command Structure

python kloc.py <command> [options]

Commands

get - Get path for configuration files

This command helps you locate the kloc.config.json and .klocignore files.

  • Get kloc.config.json path:

    python kloc.py get --config
  • Get .klocignore path:

    python kloc.py get --ignore
  • Interactive selection:

    python kloc.py get

    This will prompt you to choose which file's path you want to see, allowing selection by number or arrow keys.

count - Count lines of code

This command counts lines of code in the current directory based on various output formats.

  • Display total lines of code (oneline):

    python kloc.py count -ol
  • Display lines of code for each file (tree format):

    python kloc.py count -fi
  • Display lines of code for each language (table format):

    python kloc.py count -ta
  • Interactive selection:

    python kloc.py count

    This will prompt you to choose your desired output format, allowing selection by number or arrow keys.

Configuration Files

  • kloc.config.json (Optional): This file can be used to define custom language mappings, comment styles, and more. (Currently, this Python clone uses a basic internal language mapping. Future enhancements could include reading this file for more advanced configuration.)

    Example (not yet fully implemented in Python clone):

    {
      "languages": {
        "Python": {
          "extensions": [".py"],
          "comments": ["#"]
        },
        "JavaScript": {
          "extensions": [".js", ".jsx"],
          "comments": ["//", "/*", "*/"]
        }
      }
    }
  • .klocignore (Optional): Similar to .gitignore, this file specifies patterns for files and directories that should be ignored during the line counting process. Each line represents a pattern.

    Example:

    node_modules/
    .git/
    *.log
    temp/
    

Example Workflow

  1. Create a .klocignore file in your project root to exclude unwanted directories/files.
  2. Run python kloc.py count -ta to see a summary of lines of code by language.
  3. Run python kloc.py count -fi to inspect line counts per file.

About

Know how many lines of code you have in your working directory — blazingly fast.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages