Category: Importer (takes in a JSON generated by Tokei and outputs cc.json)

The TokeiImporter lets you import json files generated by Tokei into CodeCharta. Tokei is a program that computes basic metrics for your code. It supports a large amount of different languages.

Supported languages

  • Over 200 (click here for a list of all)

Supported Metrics

  • Lines
  • Lines of Code
  • Lines of comments
  • Blank lines

Usage and Parameters

Parameter Description
<FILE> Tokei generated JSON file
-h, --help displays this help and exits
-o, --output-file=<outputFile> output File (or empty for stdout)
-r, --root-name=<rootName> root folder as specified when executing tokei
--path-separator=<pathSeparator> path separator, leave empty for auto-detection UNIX/Windows (default = ‘/’)
-nc, --not-compressed don’t compress output to gzip, output JSON instead
Usage: ccsh tokeiimporter [-h] [--path-separator=<pathSeparator>]
                          [-o=<outputFile>] [-r=<rootName>] [-nc]
                          [FILE]

Examples

ccsh tokeiimporter tokei_results.json --path-separator=\\ -o output.cc.json

Results of Tokei can also directly be piped into the Tokei importer like this:

tokei yourCode -o json | ccsh tokeiimporter -r yourCode

Installing Tokei

There are several ways to install Tokei.

On the release posts you can download binaries for Linux and MacOS as well as executables for Windows.

If you want to build it yourself, check the repository directly or this guide:

  1. Make sure you have Rust and the C++ Build Tools of Visual Studio installed.
  2. Build Tokei from source
    $ git clone https://github.com/XAMPPRocky/tokei.git
    $ cd tokei
    $ cargo build --release
    
  3. Install Tokei with enabled json support cargo install tokei --features json
  4. Add Tokei to your PATH variable if necessary

Analyze a Project with Tokei

Run

tokei . --output json > tokei_results.json

in the project’s root folder to analyze the project.

Updated: