1# Tokei ([時計](https://en.wiktionary.org/wiki/%E6%99%82%E8%A8%88)) 2[![Mean Bean CI](https://github.com/XAMPPRocky/tokei/workflows/Mean%20Bean%20CI/badge.svg)](https://github.com/XAMPPRocky/tokei/actions?query=workflow%3A%22Mean+Bean+CI%22) 3[![crates.io](https://img.shields.io/crates/d/tokei.svg)](https://crates.io/crates/tokei) 4[![Help Wanted](https://img.shields.io/github/issues/XAMPPRocky/tokei/help%20wanted?color=green)](https://github.com/XAMPPRocky/tokei/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) 5[![Lines Of Code](https://tokei.rs/b1/github/XAMPPRocky/tokei?category=code)](https://github.com/XAMPPRocky/tokei) 6[![Documentation](https://docs.rs/tokei/badge.svg)](https://docs.rs/tokei/) 7 8Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language. 9 10### Translations 11- [中文](https://github.com/chinanf-boy/tokei-zh#支持的语言) 12 13## Example 14```console 15=============================================================================== 16 Language Files Lines Code Comments Blanks 17=============================================================================== 18 BASH 4 49 30 10 9 19 JSON 1 1332 1332 0 0 20 Shell 1 49 38 1 10 21 TOML 2 77 64 4 9 22------------------------------------------------------------------------------- 23 Markdown 5 1355 0 1074 281 24 |- JSON 1 41 41 0 0 25 |- Rust 2 53 42 6 5 26 |- Shell 1 22 18 0 4 27 (Total) 1471 101 1080 290 28------------------------------------------------------------------------------- 29 Rust 19 3416 2840 116 460 30 |- Markdown 12 351 5 295 51 31 (Total) 3767 2845 411 511 32=============================================================================== 33 Total 32 6745 4410 1506 829 34=============================================================================== 35``` 36 37## [API Documentation](https://docs.rs/tokei) 38 39## Table of Contents 40 41- [Features](#features) 42- [Installation](#installation) 43 - [Package Managers](#package-managers) 44 - [Manual](#manual) 45- [Configuration](#configuration) 46- [How to use Tokei](#how-to-use-tokei) 47- [Options](#options) 48- [Badges](#badges) 49- [Plugins](#plugins) 50- [Supported Languages](#supported-languages) 51- [Changelog](CHANGELOG.md) 52- [Common Issues](#common-issues) 53- [Canonical Source](#canonical-source) 54- [Copyright and License](#copyright-and-license) 55 56## Features 57 58- Tokei is **very fast**, and is able to count millions of lines of code in seconds. 59 Check out the [12.0.0 release](https://github.com/XAMPPRocky/tokei/releases/v12.0.0) 60 to see how Tokei's speed compares to others. 61 62- Tokei is **accurate**, Tokei correctly handles multi line comments, 63 nested comments, and not counting comments that are in strings. Providing an 64 accurate code statistics. 65 66- Tokei has huge range of languages, supporting over **150** languages, and 67 their various extensions. 68 69- Tokei can output in multiple formats(**CBOR**, **JSON**, **YAML**) 70 allowing Tokei's output to be easily stored, and reused. These can also be 71 reused in tokei combining a previous run's statistics with another set. 72 73- Tokei is available on **Mac**, **Linux**, and **Windows**. See [installation 74 instructions](#installation) for how to get Tokei on your platform. 75 76- Tokei is also a **library** allowing you to easily integrate it with other 77 projects. 78 79## Installation 80 81### Package Managers 82 83#### Linux 84```console 85# Alpine Linux (since 3.13) 86apk add tokei 87# Arch Linux 88pacman -S tokei 89# Cargo 90cargo install tokei 91# Conda 92conda install -c conda-forge tokei 93# Fedora 94sudo dnf install tokei 95# FreeBSD 96pkg install tokei 97# NetBSD 98pkgin install tokei 99# Nix/NixOS 100nix-env -i tokei 101# OpenSUSE 102sudo zypper install tokei 103``` 104 105#### macOS 106```console 107# Homebrew 108brew install tokei 109# MacPorts 110sudo port selfupdate 111sudo port install tokei 112``` 113 114#### Windows 115```console 116scoop install tokei 117``` 118 119### Manual 120 121#### Downloading 122You can download prebuilt binaries in the 123[releases section](https://github.com/XAMPPRocky/tokei/releases). 124 125#### Building 126You can also build and install from source (requires the latest stable [Rust] compiler.) 127```console 128cargo install --git https://github.com/XAMPPRocky/tokei.git 129``` 130 131[rust]: https://www.rust-lang.org 132 133 134## Configuration 135 136Tokei has a [configuration] file that allows you to change default behaviour. 137The file can be named `tokei.toml` or `.tokeirc`. Currently tokei looks for 138this file in three different places. The current directory,your home directory, 139and your configuration directory. 140 141## How to use Tokei 142 143#### Basic usage 144 145This is the basic way to use tokei. Which will report on the code in `./foo` 146and all subfolders. 147 148```shell 149$ tokei ./foo 150``` 151 152[configuration]: ./tokei.example.toml 153 154#### Multiple folders 155To have tokei report on multiple folders in the same call simply add a comma, 156or a space followed by another path. 157 158```shell 159$ tokei ./foo ./bar ./baz 160``` 161```shell 162$ tokei ./foo, ./bar, ./baz 163``` 164 165#### Excluding folders 166Tokei will respect all `.gitignore` and `.ignore` files, and you can use 167the `--exclude` option to exclude any additional files. The `--exclude` flag has 168the same semantics as `.gitignore`. 169 170```shell 171$ tokei ./foo --exclude *.rs 172``` 173 174#### Sorting output 175By default tokei sorts alphabetically by language name, however using `--sort` 176tokei can also sort by any of the columns. 177 178`blanks, code, comments, lines` 179 180```shell 181$ tokei ./foo --sort code 182``` 183 184#### Outputting file statistics 185By default tokei only outputs the total of the languages, and using `--files` 186flag tokei can also output individual file statistics. 187 188```shell 189$ tokei ./foo --files 190``` 191 192#### Outputting into different formats 193Tokei normally outputs into a nice human readable format designed for terminals. 194There is also using the `--output` option various other formats that are more 195useful for bringing the data into another program. 196 197**Note:** This version of tokei was compiled without any serialization formats, to enable serialization, reinstall 198tokei with the features flag. 199 200```shell 201 ALL: 202 cargo install tokei --features all 203 204 JSON: 205 cargo install tokei --features json 206 207 CBOR: 208 cargo install tokei --features cbor 209 210 YAML: 211 cargo install tokei --features yaml 212``` 213 214**Currently supported formats** 215- JSON `--output json` 216- YAML `--output yaml` 217- CBOR `--output cbor` 218 219```shell 220$ tokei ./foo --output json 221``` 222 223#### Reading in stored formats 224Tokei can also take in the outputted formats added in the previous results to it's 225current run. Tokei can take either a path to a file, the format passed in as a 226value to the option, or from stdin. 227 228```shell 229$ tokei ./foo --input ./stats.json 230``` 231 232## Options 233 234``` 235USAGE: 236 tokei [FLAGS] [OPTIONS] [--] [input]... 237 238FLAGS: 239 -f, --files Will print out statistics on individual files. 240 -h, --help Prints help information 241 --hidden Count hidden files. 242 -l, --languages Prints out supported languages and their extensions. 243 --no-ignore Don't respect ignore files (.gitignore, .ignore, etc.). This implies --no-ignore-parent, 244 --no-ignore-dot, and --no-ignore-vcs. 245 --no-ignore-dot Don't respect .ignore and .tokeignore files, including those in parent directories. 246 --no-ignore-parent Don't respect ignore files (.gitignore, .ignore, etc.) in parent directories. 247 --no-ignore-vcs Don't respect VCS ignore files (.gitignore, .hgignore, etc.), including those in parent 248 directories. 249 -V, --version Prints version information 250 -v, --verbose Set log output level: 251 1: to show unknown file extensions, 252 2: reserved for future debugging, 253 3: enable file level trace. Not recommended on multiple files 254 255OPTIONS: 256 -c, --columns <columns> Sets a strict column width of the output, only available for terminal output. 257 -e, --exclude <exclude>... Ignore all files & directories matching the pattern. 258 -i, --input <file_input> Gives statistics from a previous tokei run. Can be given a file path, or "stdin" to 259 read from stdin. 260 -o, --output <output> Outputs Tokei in a specific format. Compile with additional features for more format 261 support. [possible values: cbor, json, yaml] 262 -s, --sort <sort> Sort languages based on column [possible values: files, lines, blanks, code, comments] 263 -t, --type <types> Filters output by language type, seperated by a comma. i.e. -t=Rust,Markdown 264 265ARGS: 266 <input>... The path(s) to the file or directory to be counted. 267``` 268 269## Badges 270Tokei has support for badges. For example 271[![](https://tokei.rs/b1/github/XAMPPRocky/tokei)](https://github.com/XAMPPRocky/tokei). 272 273``` 274[![](https://tokei.rs/b1/github/XAMPPRocky/tokei)](https://github.com/XAMPPRocky/tokei). 275``` 276 277Tokei's URL scheme is as follows. 278 279``` 280https://tokei.rs/b1/{host: values: github|gitlab}/{Repo Owner eg: XAMPPRocky}/{Repo name eg: tokei} 281``` 282 283By default the badge will show the repo's LoC(_Lines of Code_), you can also 284specify for it to show a different category, by using the `?category=` query 285string. It can be either `code`, `blanks`, `files`, `lines`, `comments`, 286Example show total lines: 287 288``` 289[![](https://tokei.rs/b1/github/XAMPPRocky/tokei?category=lines)](https://github.com/XAMPPRocky/tokei). 290``` 291 292The server code hosted on tokei.rs is in [XAMPPRocky/tokei_rs](https://github.com/XAMPPRocky/tokei_rs) 293 294## Plugins 295Thanks to contributors tokei is now available as a plugin for some text editors. 296 297- [Vim](https://github.com/vmchale/tokei-vim) by [vmchale](https://github.com/vmchale/) 298 299## Supported Languages 300 301If there is a language that you would to add to tokei feel free to make a pull 302request. Languages are defined in [`languages.json`](./languages.json), and you can 303read how to add and test your language in our [CONTRIBUTING.md](./CONTRIBUTING.md). 304 305``` 306Abap 307ActionScript 308Ada 309Agda 310Alex 311Alloy 312Asn1 313Asp 314AspNet 315Assembly 316AssemblyGAS 317Autoconf 318AutoHotKey 319Automake 320Bash 321Batch 322BrightScript 323C 324Cabal 325Cassius 326Ceylon 327CHeader 328Clojure 329ClojureC 330ClojureScript 331CMake 332Cobol 333CoffeeScript 334Cogent 335ColdFusion 336ColdFusionScript 337Coq 338Cpp 339CppHeader 340Crystal 341CSharp 342CShell 343Css 344D 345DAML 346Dart 347DeviceTree 348Dhall 349Dockerfile 350DotNetResource 351DreamMaker 352Dust 353Edn 354Elisp 355Elixir 356Elm 357Elvish 358EmacsDevEnv 359Emojicode 360Erlang 361FEN 362Fish 363FlatBuffers 364Forth 365FortranLegacy 366FortranModern 367FreeMarker 368FSharp 369Fstar 370GDB 371GdScript 372Gherkin 373Gleam 374Glsl 375Go 376Graphql 377Groovy 378Gwion 379Hamlet 380Handlebars 381Happy 382Haskell 383Haxe 384Hcl 385Hex 386Hlsl 387HolyC 388Html 389Idris 390Ini 391IntelHex 392Isabelle 393Jai 394Java 395JavaScript 396Json 397Jsx 398Julia 399Julius 400KakouneScript 401Kotlin 402Lean 403Less 404LinkerScript 405Liquid 406Lisp 407LLVM 408Logtalk 409Lua 410Lucius 411Madlang 412Makefile 413Markdown 414Meson 415Mint 416ModuleDef 417MoonScript 418MsBuild 419Mustache 420Nim 421Nix 422NotQuitePerl 423ObjectiveC 424ObjectiveCpp 425OCaml 426Odin 427Org 428Oz 429Pascal 430Perl 431Perl6 432Pest 433Php 434Polly 435Pony 436PostCss 437PowerShell 438Processing 439Prolog 440Protobuf 441PSL 442PureScript 443Python 444Qcl 445Qml 446R 447Racket 448Rakefile 449Razor 450Renpy 451ReStructuredText 452RON 453RPMSpecfile 454Ruby 455RubyHtml 456Rust 457Sass 458Scala 459Scheme 460Scons 461Sh 462Sml 463Solidity 464SpecmanE 465Spice 466Sql 467SRecode 468Stratego 469Svelte 470Svg 471Swift 472Swig 473SystemVerilog 474Tcl 475Tex 476Text 477Thrift 478Toml 479Tsx 480Twig 481TypeScript 482UnrealDeveloperMarkdown 483UnrealPlugin 484UnrealProject 485UnrealScript 486UnrealShader 487UnrealShaderHeader 488UrWeb 489UrWebProject 490Vala 491VB6 492VBScript 493Velocity 494Verilog 495VerilogArgsFile 496Vhdl 497VimScript 498VisualBasic 499VisualStudioProject 500VisualStudioSolution 501Vue 502WebAssembly 503Wolfram 504Xaml 505XcodeConfig 506Xml 507XSL 508Xtend 509Yaml 510Zig 511Zsh 512``` 513 514## Common issues 515 516### Tokei says I have a lot of D code, but I know there is no D code! 517This is likely due to `gcc` generating `.d` files. Until the D people decide on 518a different file extension, you can always exclude `.d` files using the 519`-e --exclude` flag like so 520 521``` 522$ tokei . -e *.d 523``` 524 525## Canonical Source 526The canonical source of this repo is hosted on 527[GitHub](https://github.com/XAMPPRocky/tokei). If you have a GitHub account, 528please make your issues, and pull requests there. 529 530## Copyright and License 531(C) Copyright 2015 by XAMPPRocky and contributors 532 533See [the graph](https://github.com/XAMPPRocky/tokei/graphs/contributors) for a full list of contributors. 534 535Tokei is distributed under the terms of both the MIT license and the Apache License (Version 2.0). 536 537See [LICENCE-APACHE](./LICENCE-APACHE), [LICENCE-MIT](./LICENCE-MIT) for more information. 538