Skip to content

clocrt - transform cloc output into a Markdown table

License

Notifications You must be signed in to change notification settings

michalspano/clocrt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clocrt - Count Lines of Code Redefined Tables

Forks Stargazers Issues Contributors Release MIT License

Table of Contents

Introduction

A simple, lightweight CLI tool to transform a cloc output into a Markdown table written in Go.

Requirements

  1. A unix-like operating system (with either bash or sh, etc.);
  2. The cloc command-line utility;
  3. The wget command-line utility.

*The wget command-line utility is used to download the clocrt binary. Indeed, clocrt is not a fork of cloc, and therefore, cloc is a direct dependency of clocrt.

Additional

A copy of the Go binary is needed to install the clocrt binary from the source. The Go binary is available here.

Installation

The automated installation is carried with a single command:

$ curl -s https://raw.githubusercontent.com/michalspano/clocrt/main/install | sh

Build from the source

$ git clone https://github.com/michalspano/clocrt.git && cd clocrt
$ go build -o clocrt src/main.go
$ ./clocrt --version  # validates the installation

Example

Suppose the following working tree with some dummy files:

$ tree ./test

test
├── docs
│   └── foo.md
├── foo.go
└── foo.py

Running cloc would yield the following output:

$ cloc ./test

       3 text files.
       3 unique files.                              
       0 files ignored.

github.com/AlDanial/cloc v 1.94  T=0.00 s (626.3 files/s, 1878.9 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Go                               1              2              0              5
Markdown                         1              0              0              1
Python                           1              0              0              1
-------------------------------------------------------------------------------
SUM:                             3              2              0              7
-------------------------------------------------------------------------------

Which we transform into a Markdown table with clocrt:

$ clocrt "`cloc ./test`"

github.com/AlDanial/cloc v 1.94 T=0.00 s (626.3 files/s, 1878.9 lines/s)

Language files blank comment code
Go 1 2 0 5
Markdown 1 0 0 1
Python 1 0 0 1
SUM: 3 2 0 7

*Markdown table syntax: link

Voila! 🎊

Usage

$ clocrt -h 
$ clocrt --help

NAME
        clocrt - count lines of code redefined tables

DESCRIPTION
        A simple, lightweight CLI tool to transform a cloc output into a Markdown table.

USAGE
        clocrt "`[CLOC-PATTERN]`" [OPTIONS]

OPTIONS
        --help, -h                       show the usage
        --version, -v                    fetch and display the current version

        --print, -pr                     print the result to stdout
        --cell-align|-ca=<align>         center|c (default), left|l, right|r
        --output-path|-op=<path>         output file path (default: out.md)
BUGS
         Don't forget to quote the pattern per the example: "`[CLOC-PATTERN]`"

cloc docs

Documentation of the cloc command-line utility can be found here.

Contributing

I'm open to any contribution to the repository. If you have any suggestions or feedback, please open an issue or pull request. 👍 With the respect to the MIT License provided within the project: link.

About

clocrt - transform cloc output into a Markdown table

Topics

Resources

License

Stars

Watchers

Forks