Go to file
Stefan Maric d46d511cd8 Add GraphQL support (#306)
* Add GraphQL support

* Fix line count on Graphql test file

* Add extra final new line to GraphQL test file

* Fix line counts on graphql test file

* Fix typo on graphql test file
2019-03-04 09:08:15 +01:00
ci Updated CI to test and deploy featured versions 2018-02-22 14:20:44 +00:00
resources Updated v8.0.0 and added comparison document 2018-08-25 22:00:24 +01:00
src limit width to 80 unless --files is specified (#289) 2019-01-22 09:29:54 +01:00
tests Add GraphQL support (#306) 2019-03-04 09:08:15 +01:00
.gitattributes version 5: optimised stats, language generation 2017-01-03 00:02:18 +00:00
.gitignore Updated .gitignore 2018-08-25 21:10:11 +01:00
.tokeirc.example Implemented config files 2019-01-10 11:11:39 +01:00
.travis.yml Comment out x86_64-unknown-netbsd 2018-09-07 08:40:52 +01:00
appveyor.yml Updated CI 2018-04-16 18:08:54 +01:00
benchmark.sh Refactor, and use buffered io for output 2018-10-08 16:55:47 +01:00
build.rs Implemented config files 2019-01-10 11:11:39 +01:00
Cargo.lock Bump version 2019-01-13 21:22:53 +01:00
Cargo.toml Bump version 2019-01-13 21:22:53 +01:00
CHANGELOG.md Update CHANGELOG.md 2019-01-13 21:30:46 +01:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2017-07-04 16:22:45 +01:00
COMPARISON.md clarified cloc's speed vs cloc's time (#281) 2018-11-11 23:11:22 +00:00
CONTRIBUTING.md Add support for ClojureC + tests for all Clojure (#224) 2018-04-26 16:34:47 +01:00
languages.json Add GraphQL support (#306) 2019-03-04 09:08:15 +01:00
LICENCE-APACHE reimplemented comment syntax again, added OCaml, and Standard ML 2016-01-26 20:23:21 +00:00
LICENCE-MIT reimplemented comment syntax again, added OCaml, and Standard ML 2016-01-26 20:23:21 +00:00
README.md Add solidity support (#303) 2019-02-14 14:11:51 +01:00

Tokei (時計)

Linux build status Windows build status Documentation Donate using Liberapay

Tokei is a program that displays statistics about your code. Tokei will show number of files, total lines within those files and code, comments, and blanks grouped by language.

Translations

Example Output

This is tokei running on its own directory

asciicast

Documentation

Table of Contents

Features

  • Tokei is very fast, check out our comparison document to see how Tokei's speed compares to others.

  • Tokei is accurate, Tokei correctly handles multi line comments, nested comments, and not counting comments that are in strings. Providing an accurate code statistics.

  • Tokei has huge range of languages, supporting over 150 languages, and their various extensions.

  • Tokei can output in multiple formats(CBOR, JSON, TOML, YAML) allowing Tokei's output to be easily stored, and reused. These can also be reused in tokei combining a previous run's statistics with another set.

  • Tokei is available on Mac, Linux, and Windows. See installation instructions for how to get Tokei on your platform.

  • Tokei is also a library allowing you to easily integrate it with other projects.

Installation

Automatic

Arch Linux

$ pacman -S tokei

Cargo

$ cargo install tokei

Conda

$ conda install -c conda-forge tokei

Fedora

$ sudo dnf install tokei

FreeBSD

$ pkg install tokei

Homebrew

$ brew install tokei

Nix/NixOS

$ nix-env -i tokei

Manual

You can download prebuilt binaries in the releases section, or create from source.

$ git clone https://github.com/Aaronepower/tokei.git
$ cd tokei
$ cargo build --release
Linux
# sudo mv target/release/tokei /usr/local/bin
OSX
# sudo mv target/release/tokei /usr/local/bin/tokei
Windows
  • Create a folder for tokei
  • search for env
  • open "edit your enviroment variables"
  • edit PATH
  • append folder path to the end of the string ie: <path_stuff_here>;C:/tokei/;

How to use Tokei

Basic usage

This is the basic way to use tokei. Which will report on the code in ./foo and all subfolders.

$ tokei ./foo

Multiple folders

To have tokei report on multiple folders in the same call simply add a comma, or a space followed by another path.

$ tokei ./foo ./bar ./baz
$ tokei ./foo, ./bar, ./baz

Excluding folders

Tokei will respect all .gitignore and .ignore files, and you can use the --exclude option to exclude any additional files. The --exclude flag has the same semantics as .gitignore.

$ tokei ./foo --exclude *.rs

Sorting output

By default tokei sorts alphabetically by language name, however using --sort tokei can also sort by any of the columns.

blanks, code, comments, lines

$ tokei ./foo --sort code

Outputting file statistics

By default tokei only outputs the total of the languages, and using --files flag tokei can also output individual file statistics.

$ tokei ./foo --files

Outputting into different formats

Tokei normally outputs into a nice human readable format designed for terminals. There is also using the --output option various other formats that are more useful for bringing the data into another program.

Note: This version of tokei was compiled without any serialization formats, to enable serialization, reinstall tokei with the features flag.

  ALL:
  cargo install tokei --features all

  JSON:
  cargo install tokei --features json

  CBOR:
  cargo install tokei --features cbor

  YAML:
  cargo install tokei --features yaml

  CBOR:
  cargo install tokei --features cbor

Currently supported formats

  • JSON --output json
  • YAML --output yaml
  • TOML --output toml
  • CBOR --output cbor
$ tokei ./foo --output json

Reading in stored formats

Tokei can also take in the outputted formats added in the previous results to it's current run. Tokei can take either a path to a file, the format passed in as a value to the option, or from stdin.

$ tokei ./foo --input ./stats.json

Options

tokei 7.0.1
Aaron P. <theaaronepower@gmail.com> + Contributors
A utility that allows you to count code, quickly.

USAGE:
    tokei [FLAGS] [OPTIONS] [--] [input]...

FLAGS:
    -f, --files        Will print out statistics on individual files.
    -h, --help         Prints help information
    -l, --languages    Prints out supported languages and their extensions.
    -V, --version      Prints version information
    -v, --verbose      Set log output level:
                                1: to show unknown file extensions,
                                2: reserved for future debugging,
                                3: enable file level trace. Not recommended on multiple files

OPTIONS:
    -e, --exclude <exclude>...    Ignore all files & directories containing the word.
    -i, --input <file_input>      Gives statistics from a previous tokei run. Can be given a file path, or "stdin" to
                                  read from stdin.
    -o, --output <output>         Outputs Tokei in a specific format. [values: cbor, json, toml, yaml]
    -s, --sort <sort>             Sort languages based on column [values: files, lines, blanks, code, comments]

ARGS:
    <input>...    The input file(s)/directory(ies) to be counted.

Badges

Tokei has support for badges. For example .

[![](https://tokei.rs/b1/github/Aaronepower/tokei)](https://github.com/Aaronepower/tokei).

Tokei's URL scheme is as follows.

https://tokei.rs/b1/{host: values: github|gitlab}/{Repo Owner eg: Aaronepower}/{Repo name eg: tokei}

By default the badge will show the repo's LoC(Lines of Code), you can also specify for it to show a different category, by using the ?category= query string. It can be either code, blanks, files, lines, comments, Example show total lines:

[![](https://tokei.rs/b1/github/Aaronepower/tokei?category=lines)](https://github.com/Aaronepower/tokei).

Plugins

Thanks to contributors tokei is now available as a plugin for some text editors.

Supported Languages

If there is a language that you want added, feel free to submit a pull request with the following information. If you're unsure have a look at languages.json to see how other languages are defined.

  • Name of language
  • File Extension(s)
  • The comment syntax (Does it have block comments? is it the same as C?)
  • The string literal syntax
ABAP
ActionScript
Ada
Agda
Alex
ASP
ASP.NET
Assembly
AutoHotKey
Autoconf
Automake
BASH
Batch
BrightScript
C
C Header
CMake
C#
C Shell
Cabal
Cassius
Ceylon
Clojure
ClojureC
ClojureScript
COBOL
CoffeeScript
Cogent
ColdFusion
ColdFusion CFScript
Coq
C++
C++ Header
Crystal
CSS
D
Dart
Device Tree
Dockerfile
.NET Resource
Dream Maker
Edn
Emacs Lisp
Elixir
Elm
Elvish
Emacs Dev Env
Erlang
FEN
F#
Fish
Forth
FORTRAN Legacy
FORTRAN Modern
F*
GDScript
GLSL
Go
Groovy
Hamlet
Handlebars
Happy
Haskell
Haxe
HCL
HEX
HLSL
HTML
Idris
INI
Intel HEX
Isabelle
JAI
Java
JavaScript
JSON
JSX
Julia
Julius
Kakoune script
Kotlin
Lean
LESS
LD Script
Liquid
Lisp
Logtalk
Lua
Lucius
Madlang
Makefile
Markdown
Meson
Mint
Module-Definition
MSBuild
Mustache
Nim
Nix
Not Quite Perl
OCaml
Objective C
Objective C++
Org
Oz
PSL Assertion
Pascal
Perl
Perl6
PHP
Polly
Processing
Prolog
Protocol Buffers
PureScript
Python
QCL
QML
R
Racket
Rakefile
Razor
ReStructuredText
Ruby
Ruby HTML
Rust
SRecode Template
Sass
Scala
Scheme
Scons
Shell
Standard ML (SML)
Solidity
Specman e
Spice Netlist
SQL
SVG
Swift
SWIG
SystemVerilog
TCL
TeX
Plain Text
TOML
Twig
TypeScript
Unreal Markdown
Unreal Plugin
Unreal Project
Unreal Script
Unreal Shader
Unreal Shader Header
Ur/Web
Ur/Web Project
VB6
VBScript
Vala
Verilog
Verilog Args File
VHDL
Vim Script
Visual Basic
Visual Studio Project
Visual Studio Solution
Vue
Wolfram
XSL
XAML
XCode Config
XML
Xtend
YAML
Zig
Zsh

Common issues

Tokei says I have a lot of D code, but I know there is no D code!

This is likely due to gcc generating .d files. Until the D people decide on a different file extension, you can always exclude .d files using the -e --exclude flag like so

$ tokei . -e *.d

Canonical Source

The canonical source of this repo is hosted on GitHub. If you have a GitHub account, please make your issues, and pull requests there.

(C) Copyright 2015 by Aaron Power and contributors

See CONTRIBUTORS.md for a full list of contributors.

Tokei is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENCE-APACHE, LICENCE-MIT for more information.