No description
Find a file
dependabot-preview[bot] 9624d1cd2c Bump regex from 1.4.1 to 1.4.2
Bumps [regex](https://github.com/rust-lang/regex) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.4.1...1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 04:54:14 +00:00
.github Update mean_bean_ci.yml 2020-08-17 10:48:23 +02:00
ci Update build.bash 2020-05-28 05:45:18 +02:00
src Make --no-ignore imply all other --no-ignore- flags (#588) 2020-09-20 15:30:35 +02:00
tests add stan language (#633) 2020-10-26 16:28:34 +01:00
.gitattributes version 5: optimised stats, language generation 2017-01-03 00:02:18 +00:00
.gitignore Refactor context parsing and add initial support for HTML. 2020-06-21 15:15:16 +02:00
.mailmap update mailmap 2020-03-18 11:28:47 +01:00
.tokeignore Added .tokeignore 2019-03-31 03:58:49 +02:00
benchmark.sh Add parallel count heuristic 2020-03-21 13:12:15 +01:00
build.rs use raw string in build 2020-06-21 21:17:01 +02:00
Cargo.lock Bump regex from 1.4.1 to 1.4.2 2020-11-02 04:54:14 +00:00
Cargo.toml Bump regex from 1.4.1 to 1.4.2 2020-11-02 04:54:14 +00:00
CHANGELOG.md Version bump 2020-06-22 13:32:44 +02:00
CODE_OF_CONDUCT.md Updated documentation 2019-07-04 22:21:27 +02:00
CONTRIBUTING.md Refactor cli_utils into Printer and add Rust context 2020-06-19 08:44:03 +02:00
languages.json add stan language (#633) 2020-10-26 16:28:34 +01:00
LICENCE-APACHE Update LICENCE-APACHE 2020-07-31 12:27:00 +02:00
LICENCE-MIT Update LICENCE-MIT 2020-07-31 12:26:48 +02:00
README.md Update README.md 2020-10-23 15:22:27 +02:00
tokei.example.toml Specify the --sort option in the configuration files (#550) 2020-06-02 14:03:54 +02:00

Tokei (時計)

Mean Bean CI crates.io Help Wanted Lines Of Code Documentation

Tokei 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.

Translations

Example

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 BASH                    4           49           30           10            9
 JSON                    1         1332         1332            0            0
 Shell                   1           49           38            1           10
 TOML                    2           77           64            4            9
-------------------------------------------------------------------------------
 Markdown                5         1355            0         1074          281
 |- JSON                 1           41           41            0            0
 |- Rust                 2           53           42            6            5
 |- Shell                1           22           18            0            4
 (Total)                           1471          101         1080          290
-------------------------------------------------------------------------------
 Rust                   19         3416         2840          116          460
 |- Markdown            12          351            5          295           51
 (Total)                           3767         2845          411          511
===============================================================================
 Total                  32         6745         4410         1506          829
===============================================================================

API Documentation

Table of Contents

Features

  • Tokei is very fast, and is able to count millions of lines of code in seconds. Check out the 12.0.0 release 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

Package Managers

Linux

# 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
# Nix/NixOS
nix-env -i tokei
# OpenSUSE
sudo zypper install tokei

macOS

# Homebrew
brew install tokei
# MacPorts
sudo port selfupdate
sudo port install tokei

Windows

scoop install tokei

Manual

Downloading

You can download prebuilt binaries in the releases section.

Building

You can also build and install from source (requires the latest stable Rust compiler.)

cargo install --git https://github.com/XAMPPRocky/tokei.git

Configuration

Tokei has a configuration file that allows you to change default behaviour. The file can be named tokei.toml or .tokeirc. Currently tokei looks for this file in three different places. The current directory,your home directory, and your configuration directory.

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

Currently supported formats

  • JSON --output json
  • YAML --output yaml
  • 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

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

FLAGS:
    -f, --files               Will print out statistics on individual files.
    -h, --help                Prints help information
        --hidden              Count hidden files.
    -l, --languages           Prints out supported languages and their extensions.
        --no-ignore           Don't respect ignore files (.gitignore, .ignore, etc.). This implies --no-ignore-parent,
                              --no-ignore-dot, and --no-ignore-vcs.
        --no-ignore-dot       Don't respect .ignore and .tokeignore files, including those in parent directories.
        --no-ignore-parent    Don't respect ignore files (.gitignore, .ignore, etc.) in parent directories.
        --no-ignore-vcs       Don't respect VCS ignore files (.gitignore, .hgignore, etc.), including those in parent
                              directories.
    -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:
    -c, --columns <columns>       Sets a strict column width of the output, only available for terminal output.
    -e, --exclude <exclude>...    Ignore all files & directories matching the pattern.
    -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. Compile with additional features for more format
                                  support. [possible values: cbor, json, yaml]
    -s, --sort <sort>             Sort languages based on column [possible values: files, lines, blanks, code, comments]
    -t, --type <types>            Filters output by language type, seperated by a comma. i.e. -t=Rust,Markdown

ARGS:
    <input>...    The path(s) to the file or directory to be counted.

Badges

Tokei has support for badges. For example .

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

Tokei's URL scheme is as follows.

https://tokei.rs/b1/{host: values: github|gitlab}/{Repo Owner eg: XAMPPRocky}/{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/XAMPPRocky/tokei?category=lines)](https://github.com/XAMPPRocky/tokei).

The server code hosted on tokei.rs is in XAMPPRocky/tokei_rs

Plugins

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

Supported Languages

If there is a language that you would to add to tokei feel free to make a pull request. Languages are defined in languages.json, and you can read how to add and test your language in our CONTRIBUTING.md.

Abap
ActionScript
Ada
Agda
Alex
Alloy
Asn1
Asp
AspNet
Assembly
AssemblyGAS
Autoconf
AutoHotKey
Automake
Bash
Batch
BrightScript
C
Cabal
Cassius
Ceylon
CHeader
Clojure
ClojureC
ClojureScript
CMake
Cobol
CoffeeScript
Cogent
ColdFusion
ColdFusionScript
Coq
Cpp
CppHeader
Crystal
CSharp
CShell
Css
D
DAML
Dart
DeviceTree
Dhall
Dockerfile
DotNetResource
DreamMaker
Dust
Edn
Elisp
Elixir
Elm
Elvish
EmacsDevEnv
Emojicode
Erlang
FEN
Fish
FlatBuffers
Forth
FortranLegacy
FortranModern
FreeMarker
FSharp
Fstar
GDB
GdScript
Gherkin
Glsl
Go
Graphql
Groovy
Hamlet
Handlebars
Happy
Haskell
Haxe
Hcl
Hex
Hlsl
HolyC
Html
Idris
Ini
IntelHex
Isabelle
Jai
Java
JavaScript
Json
Jsx
Julia
Julius
KakouneScript
Kotlin
Lean
Less
LinkerScript
Liquid
Lisp
LLVM
Logtalk
Lua
Lucius
Madlang
Makefile
Markdown
Meson
Mint
ModuleDef
MoonScript
MsBuild
Mustache
Nim
Nix
NotQuitePerl
ObjectiveC
ObjectiveCpp
OCaml
Odin
Org
Oz
Pascal
Perl
Perl6
Pest
Php
Polly
Pony
PostCss
PowerShell
Processing
Prolog
Protobuf
PSL
PureScript
Python
Qcl
Qml
R
Racket
Rakefile
Razor
Renpy
ReStructuredText
RON
RPMSpecfile
Ruby
RubyHtml
Rust
Sass
Scala
Scheme
Scons
Sh
Sml
Solidity
SpecmanE
Spice
Sql
SRecode
Stratego
Svelte
Svg
Swift
Swig
SystemVerilog
Tcl
Tex
Text
Thrift
Toml
Tsx
Twig
TypeScript
UnrealDeveloperMarkdown
UnrealPlugin
UnrealProject
UnrealScript
UnrealShader
UnrealShaderHeader
UrWeb
UrWebProject
Vala
VB6
VBScript
Velocity
Verilog
VerilogArgsFile
Vhdl
VimScript
VisualBasic
VisualStudioProject
VisualStudioSolution
Vue
WebAssembly
Wolfram
Xaml
XcodeConfig
Xml
XSL
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 XAMPPRocky and contributors

See the graph 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.