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.
Supported languages
Section titled “Supported languages”- Over 200 (click here for a list of all)
Supported Metrics
Section titled “Supported Metrics”- Lines
- Lines of Code
- Lines of comments
- Blank lines
Usage and Parameters
Section titled “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 (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
Section titled “Examples”ccsh tokeiimporter tokei_results.json --path-separator=\\ -o output.cc.jsonResults of Tokei can also directly be piped into the Tokei importer like this:
tokei yourCode -o json | ccsh tokeiimporter -r yourCodeInstalling Tokei
Section titled “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:
- Make sure you have Rust and the C++ Build Tools of Visual Studio installed.
- Build Tokei from source
$ git clone https://github.com/XAMPPRocky/tokei.git$ cd tokei$ cargo build --release
- Install Tokei with enabled json support
cargo install tokei --features json - Add Tokei to your PATH variable if necessary
Analyze a Project with Tokei
Section titled “Analyze a Project with Tokei”Run
tokei . --output json > tokei_results.jsonin the project’s root folder to analyze the project.