Skip to content

Tokei Importer

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 number of different languages.

  • Over 200 (click here for a list of all)
  • Lines
  • Lines of Code
  • Lines of comments
  • Blank lines
ParameterDescription
<FILE>Tokei generated JSON file
-h, --helpdisplays 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 (default = ”)
-nc, --not-compresseddon’t compress output to gzip, output JSON instead
Usage: ccsh tokeiimporter [-h] [--path-separator=<pathSeparator>]
[-o=<outputFile>] [-r=<rootName>] [-nc]
[FILE]
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

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

Run

Terminal window
tokei . --output json > tokei_results.json

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