2016-11-28 12:26:11 +00:00
# Tokei ([時計](https://en.wiktionary.org/wiki/%E6%99%82%E8%A8%88))
2016-06-11 01:02:33 +00:00
2016-11-28 08:14:47 +00:00
[![Linux build status ](https://img.shields.io/travis/Aaronepower/tokei.svg?branch=master )](https://travis-ci.org/Aaronepower/tokei)
[![Windows build status ](https://ci.appveyor.com/api/projects/status/github/Aaronepower/tokei?svg=true )](https://ci.appveyor.com/project/Aaronepower/tokei)
2016-06-11 01:02:33 +00:00
[![ ](https://img.shields.io/crates/d/tokei.svg )](https://crates.io/crates/tokei)
2016-12-21 13:44:54 +00:00
[![ ](https://img.shields.io/github/issues-raw/Aaronepower/tokei.svg )](https://github.com/Aaronepower/tokei/issues)
[![ ](https://tokei.rs/b1/github/Aaronepower/tokei?category=code )](https://github.com/Aaronepower/tokei)
2017-08-10 08:02:52 +00:00
[![Documentation ](https://docs.rs/tokei/badge.svg )](https://docs.rs/tokei/)
2016-06-11 01:02:33 +00:00
2016-12-22 15:16:15 +00:00
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.
2016-06-11 01:02:33 +00:00
2016-10-26 23:54:58 +00:00
## Example Output
This is tokei running on it's own directory
2017-05-06 00:25:34 +00:00
[![asciicast ](https://asciinema.org/a/d14m9g1d2cyo7wvrxh0z4ck6o.png )](https://asciinema.org/a/d14m9g1d2cyo7wvrxh0z4ck6o)
2016-10-26 23:54:58 +00:00
2016-10-27 10:59:56 +00:00
## [Documentation](https://docs.rs/tokei)
2016-06-11 01:02:33 +00:00
## Table of Contents
2017-02-15 19:42:08 +00:00
- [Features ](#features )
2016-06-11 01:02:33 +00:00
- [Installation ](#installation )
2016-11-27 16:24:41 +00:00
- [Automatic ](#automatic )
2017-01-15 21:35:15 +00:00
- [Arch Linux ](#arch-linux )
- [Cargo ](#cargo )
- [Fedora ](#fedora )
2016-11-27 16:24:41 +00:00
- [Manual ](#manual )
2016-06-11 01:02:33 +00:00
- [How to use Tokei ](#how-to-use-tokei )
- [Options ](#options )
2016-12-21 13:44:54 +00:00
- [Badges ](#badges )
2017-03-17 14:04:30 +00:00
- [Plugins ](#plugins )
2016-06-11 01:02:33 +00:00
- [Supported Languages ](#supported-languages )
2016-06-11 01:10:58 +00:00
- [Changelog ](CHANGELOG.md )
2016-06-11 01:02:33 +00:00
- [Common Issues ](#common-issues )
2017-02-15 19:42:08 +00:00
- [Canonical Source ](#canonical-source )
2016-06-11 01:02:33 +00:00
- [Copyright ](#copyright )
2017-02-15 19:42:08 +00:00
## Features
2016-06-11 01:02:33 +00:00
2017-02-15 19:42:08 +00:00
- Tokei is **very fast** , below are the Tokei's times on a select few large
repositories, with a hot cache(_times are in seconds and measured using
`/usr/bin/time` on macOS Sierra, with 2.7 GHz Intel Core i7, results will vary_).
2017-02-16 02:05:17 +00:00
| Repository | Real time |
|--------------|-----------|
| DragonFlyBSD | 1.20s |
| Rust | 0.50s |
| CPython | 0.18s |
2017-02-15 19:42:08 +00:00
- 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 **100** 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](#installation) for how to get Tokei on your platform.
2016-06-11 01:02:33 +00:00
## Installation
### Automatic
2017-01-15 21:35:15 +00:00
#### Arch Linux
2016-06-11 01:02:33 +00:00
```shell
2017-01-15 21:35:15 +00:00
$ pacman -S tokei
2016-06-11 01:02:33 +00:00
```
2017-01-15 21:35:15 +00:00
#### Cargo
```shell
$ cargo install tokei
```
2016-06-11 01:02:33 +00:00
#### Fedora 64 bit
```shell
$ dnf copr enable phnxrbrn/tokei
$ dnf install tokei
```
2017-10-16 09:31:18 +00:00
#### Nix/NixOS
```shell
# using unstable nixpkgs channel
$ nix-env -i tokei
```
2017-01-15 21:35:15 +00:00
### Manual
2016-12-21 13:44:54 +00:00
You can download prebuilt binaries in the
[releases section ](https://github.com/Aaronepower/tokei/releases ), or create
from source.
2016-06-11 01:02:33 +00:00
```shell
$ 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
2016-11-27 16:24:41 +00:00
This is the basic way to use tokei. Which will report on the code in `./foo`
and all subfolders.
2016-06-11 01:02:33 +00:00
```shell
$ tokei ./foo
```
#### Multiple folders
2016-11-27 16:24:41 +00:00
To have tokei report on multiple folders in the same call simply add a comma,
or a space followed by another path.
2016-06-11 01:02:33 +00:00
2016-09-20 22:15:47 +00:00
```shell
$ tokei ./foo ./bar ./baz
```
2016-06-11 01:02:33 +00:00
```shell
$ tokei ./foo, ./bar, ./baz
```
#### Excluding folders
2016-11-27 16:24:41 +00:00
Tokei will respect all `.gitignore` and `.ignore` files, and you can optionally
the `--exclude` option to exclude any addtional files. The `--exclude` flag has
the same semantics as `.gitignore` .
2016-06-11 01:02:33 +00:00
```shell
2016-11-27 16:24:41 +00:00
$ tokei ./foo --exclude *.rs
2016-06-11 01:02:33 +00:00
```
#### Sorting output
2016-11-27 16:24:41 +00:00
By default tokei sorts alphabetically by language name, however using `--sort`
tokei can also sort by any of the columns.
2016-06-11 01:02:33 +00:00
`blanks, code, comments, lines`
```shell
$ tokei ./foo --sort code
```
#### Outputing file statistics
2016-11-27 16:24:41 +00:00
By default tokei only outputs the total of the languages, and using `--files`
flag tokei can also output individual file statistics.
2016-06-11 01:02:33 +00:00
```shell
$ tokei ./foo --files
```
#### Outputting into different formats
2016-11-27 16:24:41 +00:00
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.
2016-06-11 01:02:33 +00:00
2016-11-27 15:54:35 +00:00
**Currently supported formats**
2016-06-11 01:02:33 +00:00
- JSON `--output json`
- YAML `--output yaml`
- TOML `--output toml`
- CBOR `--output cbor`
```shell
$ tokei ./foo --output json
```
#### Reading in stored formats
2016-11-27 16:24:41 +00:00
Tokei can also take in the outputted formats added 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.
2016-06-11 01:02:33 +00:00
```shell
$ tokei ./foo --input ./stats.json
```
## Options
2016-12-21 13:44:54 +00:00
2016-06-11 01:02:33 +00:00
```
2016-12-21 13:44:54 +00:00
Tokei 4.5.3
2016-06-11 01:02:33 +00:00
Aaron P. < theaaronepower @ gmail . com >
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
2016-12-21 13:44:54 +00:00
-v, --verbose Set verbose output level: 1: for unknown extensions
2016-06-11 01:02:33 +00:00
OPTIONS:
-e, --exclude < exclude > Ignore all files & directories containing the word.
2016-12-21 13:44:54 +00:00
-i, --input < file_input > Gives statistics from a previous tokei run. Can be given a file path, or "stdin" to read from stdin.
2016-06-11 01:02:33 +00:00
-o, --output < output > Outputs Tokei in a specific format. [values: cbor, json, toml, yaml]
-s, --sort < sort > Will sort based on column [values: files, lines, blanks, code, comments]
ARGS:
< input > ... The input file(s)/directory(ies)
```
2016-12-21 13:44:54 +00:00
## Badges
Tokei has support for badges. For example
[![ ](https://tokei.rs/b1/github/Aaronepower/tokei )](https://github.com/Aaronepower/tokei).
```
[![ ](https://tokei.rs/b1/github/Aaronepower/tokei )](https://github.com/Aaronepower/tokei).
```
Tokei's URL scheme is as follows.
```
https://tokei.rs/{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).
```
2017-03-17 14:04:30 +00:00
## Plugins
Thanks to contributors tokei is now available as a plugin for some text editors.
- [Vim ](https://github.com/vmchale/tokei-vim ) by [vmchale ](https://github.com/vmchale/ )
2016-06-11 01:02:33 +00:00
## Supported Languages
2016-11-27 16:24:41 +00:00
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` ](./languages.json ) to see how other languages are defined.
2016-06-11 01:02:33 +00:00
- Name of language
2016-11-27 16:24:41 +00:00
- File Extension(s)
2016-06-11 01:02:33 +00:00
- The comment syntax (_Does it have block comments? is it the same as C?_)
2016-11-27 16:24:41 +00:00
- The string literal syntax
2016-06-11 01:02:33 +00:00
```
ActionScript
2016-09-20 22:15:47 +00:00
Ada
2017-09-18 17:52:47 +00:00
Alex
2017-02-22 21:48:00 +00:00
Agda
2016-09-20 22:15:47 +00:00
ASP
2016-11-27 16:24:41 +00:00
ASP.NET
Assembly
2016-06-11 01:02:33 +00:00
Autoconf
2017-09-18 17:52:47 +00:00
SH
2017-09-30 10:43:23 +00:00
AutoHotKey
2016-06-11 01:02:33 +00:00
BASH
2017-09-18 17:52:47 +00:00
FISH
2016-06-11 01:02:33 +00:00
Batch
C
C Header
2016-11-27 16:24:41 +00:00
C#
C Shell
2017-09-18 17:52:47 +00:00
Cabal
Cassius
Ceylon
2016-06-11 01:02:33 +00:00
Clojure
2017-06-05 14:28:52 +00:00
CMake
2016-06-11 01:02:33 +00:00
CoffeeScript
2017-02-22 21:48:00 +00:00
Cogent
2016-06-11 01:02:33 +00:00
ColdFusion
ColdFusion CFScript
Coq
C++
C++ Header
CSS
2017-09-18 17:52:47 +00:00
Crystal
2016-06-11 01:02:33 +00:00
D
Dart
Device Tree
2017-06-05 14:28:52 +00:00
Dockerfile
2016-11-27 16:24:41 +00:00
Elixir
Elm
2016-06-11 01:02:33 +00:00
Erlang
2016-09-20 22:15:47 +00:00
Forth
2017-02-22 21:48:00 +00:00
F*
F#
2016-06-11 01:02:33 +00:00
FORTRAN Legacy
FORTRAN Modern
2017-02-22 21:48:00 +00:00
GDScript
2016-10-15 15:47:59 +00:00
GLSL
2016-06-11 01:02:33 +00:00
Go
2017-09-18 17:52:47 +00:00
Happy
2016-09-20 22:15:47 +00:00
Handlebars
2016-06-11 01:02:33 +00:00
Haskell
2016-09-20 22:15:47 +00:00
HEX
2016-11-27 16:24:41 +00:00
HTML
2017-09-18 17:52:47 +00:00
Hamlet
2016-06-11 01:02:33 +00:00
Idris
2016-09-20 22:15:47 +00:00
Intel HEX
2016-06-11 01:02:33 +00:00
Isabelle
JAI
Java
JavaScript
JSON
JSX
2016-11-27 16:24:41 +00:00
Julia
2017-09-18 17:52:47 +00:00
Julius
2016-06-11 01:02:33 +00:00
Kotlin
2016-09-29 22:42:31 +00:00
Lean
2016-06-11 01:02:33 +00:00
LESS
LD Script
LISP
Lua
2017-09-18 17:52:47 +00:00
Lucius
Madlang
2016-06-11 01:02:33 +00:00
Makefile
Markdown
2017-09-18 17:52:47 +00:00
ModuleDef
2016-06-11 01:02:33 +00:00
Mustache
Nim
2017-09-18 17:52:47 +00:00
Nix
2016-11-27 16:24:41 +00:00
OCaml
2016-06-11 01:02:33 +00:00
Objective C
Objective C++
Oz
Pascal
Perl
PHP
2016-11-27 16:24:41 +00:00
Polly
2016-06-11 01:02:33 +00:00
Prolog
2016-11-27 16:24:41 +00:00
Protocol Buffers
2017-02-22 21:48:00 +00:00
PureScript
2016-06-11 01:02:33 +00:00
Python
QCL
2017-09-18 17:52:00 +00:00
QML
2016-06-11 01:02:33 +00:00
R
2017-06-05 14:28:52 +00:00
Rakefile
2016-09-20 22:15:47 +00:00
Razor
2016-11-27 16:24:41 +00:00
ReStructuredText
2016-06-11 01:02:33 +00:00
Ruby
Ruby HTML
Rust
Sass
Scala
2017-06-05 14:28:52 +00:00
Scons
2016-06-11 01:02:33 +00:00
Standard ML
SQL
2017-10-07 09:38:45 +00:00
SVG
2016-06-11 01:02:33 +00:00
Swift
2016-11-27 16:24:41 +00:00
TCL
2016-06-11 01:02:33 +00:00
TeX
Plain Text
TOML
TypeScript
Unreal Script
2017-02-22 21:48:00 +00:00
Ur/Web
2017-09-18 17:52:47 +00:00
Vala
2017-02-18 02:00:24 +00:00
VHDL
2016-11-27 16:24:41 +00:00
Vim Script
2016-06-11 01:02:33 +00:00
Wolfram
2017-09-18 17:52:47 +00:00
Xaml
2016-06-11 01:02:33 +00:00
XML
YAML
Zsh
```
## Common issues
### Tokei says I have a lot of D code, but I know there is no D code!
2016-11-27 16:24:41 +00:00
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
2016-06-11 01:02:33 +00:00
```
2016-11-27 16:24:41 +00:00
$ tokei . -e *.d
2016-06-11 01:02:33 +00:00
```
2017-02-15 19:42:08 +00:00
## Canonical Source
The canonical source of this repo is hosted on
[GitHub ](https://github.com/Aaronepower/tokei ). If you have a GitHub account,
please make your issues, and pull requests there.
2016-06-11 01:02:33 +00:00
## Copyright and License
(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-APACHE ), [LICENCE-MIT ](./LICENCE-MIT ) for more information.