Tokei是一個顯示有關您代碼的統計信息的程序。 Tokei將顯示文件的數量,這些文件和代碼中的總線路,評論和按語言分組的空白。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
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
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Tokei非常快,並且能夠在幾秒鐘內計算數百萬行代碼。查看11.0.0版本,以了解Tokei的速度與其他人的速度相比。
Tokei是準確的,Tokei正確處理多行評論,嵌套評論,而不是計算字符串中的註釋。提供準確的代碼統計信息。
Tokei具有大量的語言,支持150多種語言及其各種語言。
Tokei可以以多種格式輸出( CBOR , JSON , YAML ),允許Tokei的輸出易於存儲和重複使用。這些也可以在將上一個運行的統計數據與另一組組合的Tokei中重複使用。
Tokei可在Mac , Linux和Windows上找到。有關如何在平台上獲取Tokei的安裝說明。
Tokei也是一個庫,允許您輕鬆地將其與其他項目集成在一起。
Tokei帶來和沒有顏色。將ENV變量NO_COLOR設置為1,它將是黑色和白色。
# Alpine Linux (since 3.13)
apk add tokei
# 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
# NetBSD
pkgin install tokei
# Nix/NixOS
nix-env -i tokei
# OpenSUSE
sudo zypper install tokei
# Void Linux
sudo xbps-install tokei # Homebrew
brew install tokei
# MacPorts
sudo port selfupdate
sudo port install tokei # Winget
winget install XAMPPRocky.tokei
# Scoop
scoop install tokei您可以在“版本”部分下載預構建的二進製文件。
您也可以從源構建和安裝(需要最新的穩定生鏽編譯器。)
cargo install --git https://github.com/XAMPPRocky/tokei.git tokei Tokei有一個配置文件,可讓您更改默認行為。該文件可以命名為tokei.toml或.tokeirc 。目前,Tokei在三個不同的地方尋找此文件。當前目錄,主目錄和您的配置目錄。
這是使用Tokei的基本方法。將在./foo和所有子文件夾中報告代碼。
$ tokei ./foo要在同一呼叫中的多個文件夾上報告Tokei,只需添加一個逗號或一個空間,然後是另一個路徑。
$ tokei ./foo ./bar ./baz$ tokei ./foo, ./bar, ./bazTokei將尊重所有.gitignore和.ignore文件,您可以使用--exclude選項來排除任何其他文件。 --exclude標誌具有與.gitignore相同的語義。
$ tokei ./foo --exclude * .rs使用與.gitignore文件相同的語法,也可以在.tokeignore文件中列出排除路徑。
默認情況下,tokei按語言名稱按字母順序排列,但是使用--sort tokei也可以按任何列進行排序。
blanks, code, comments, lines
$ tokei ./foo --sort code默認情況下,Tokei僅輸出語言的總數,並且使用--files flag tokei也可以輸出單個文件統計信息。
$ tokei ./foo --filesTokei通常會輸出為終端設計的漂亮人類可讀格式。還使用--output選項各種其他格式,這些格式對於將數據帶入另一個程序更有用。
注意:此版本的Tokei是沒有任何序列化格式的編譯,以啟用序列化,重新安裝Tokei,並使用功能標誌。
ALL:
cargo install tokei --features all
CBOR:
cargo install tokei --features cbor
YAML:
cargo install tokei --features yaml當前支持格式
--output json--output yaml--output cbor $ tokei ./foo --output jsonTokei還可以採用先前結果中添加的輸出格式,以在其當前運行中。 Tokei可以採取通往文件的路徑,將格式作為選項的值或從stdin傳遞。
$ tokei ./foo --input ./stats.json 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, separated by a comma. i.e. -t=Rust,Markdown
ARGS:
<input>... The path(s) to the file or directory to be counted.
Tokei支持徽章。例如 。
[](https://github.com/XAMPPRocky/tokei).
Tokei的URL方案如下。
https://tokei.rs/b1/{host: values: github|gitlab}/{Repo Owner eg: XAMPPRocky}/{Repo name eg: tokei}
默認情況下,徽章將顯示回購的LOC(代碼行),您還可以通過使用?category= query String”指定其顯示不同的類別。它可以是code , blanks , files , lines , comments ,示例顯示總行:
[](https://github.com/XAMPPRocky/tokei).
在tokei.rs上託管的服務器代碼在xampprocky/tokei_rs中
Tokei有一個基於alpine的Docker圖像,可通過泥土構建:
earthly +docker構建後,可以使用以下方式運行圖像
docker run --rm -v /path/to/analyze:/src tokei .或者,簡單地分析當前文件夾(Linux):
docker run --rm -v $( pwd ) :/src tokei . 如果您要添加到Tokei的語言,請隨意提出拉動請求。語言是用languages.json定義的。
Abap
ActionScript
Ada
Agda
Alex
Alloy
APL
Asn1
Asp
AspNet
Assembly
AssemblyGAS
ATS
Autoconf
AutoHotKey
Automake
AWK
Bash
Batch
Bazel
Bean
Bicep
Bitbake
BQN
BrightScript
C
Cabal
Cassius
Ceylon
CHeader
Cil
Clojure
ClojureC
ClojureScript
CMake
Cobol
CoffeeScript
Cogent
ColdFusion
ColdFusionScript
Coq
Cpp
CppHeader
Crystal
CSharp
CShell
Css
Cuda
CUE
Cython
D
D2
DAML
Dart
DeviceTree
Dhall
Dockerfile
DotNetResource
DreamMaker
Dust
Ebuild
EdgeDB
Edn
Elisp
Elixir
Elm
Elvish
EmacsDevEnv
Emojicode
Erlang
Factor
FEN
Fish
FlatBuffers
ForgeConfig
Forth
FortranLegacy
FortranModern
FreeMarker
FSharp
Fstar
GDB
GdScript
GdShader
Gherkin
Gleam
Glsl
Go
Graphql
Groovy
Gwion
Hamlet
Handlebars
Happy
Hare
Haskell
Haxe
Hcl
Hex
HiCAD
hledger
Hlsl
HolyC
Html
Hy
Idris
Ini
IntelHex
Isabelle
Jai
Janet
Java
JavaScript
Jq
Json
Jsx
Julia
Julius
Just
KakouneScript
Kotlin
Lean
Less
Lingua Franca
LinkerScript
Liquid
Lisp
LLVM
Logtalk
Lua
Lucius
Madlang
Max
Makefile
Markdown
Mdx
Meson
Mint
Mlatu
ModuleDef
MonkeyC
MoonScript
MsBuild
Mustache
Nim
Nix
NotQuitePerl
NuGetConfig
Nushell
ObjectiveC
ObjectiveCpp
OCaml
Odin
OpenSCAD
OpenQASM
Org
Oz
Pascal
Perl
Perl6
Pest
Phix
Php
Po
Poke
Polly
Pony
PostCss
PowerShell
Processing
Prolog
Protobuf
PRQL
PSL
PureScript
Pyret
Python
Qcl
Qml
R
Racket
Rakefile
Razor
Renpy
ReStructuredText
RON
RPMSpecfile
Ruby
RubyHtml
Rust
Sass
Scala
Scheme
Scons
Sh
ShaderLab
Slang
Sml
Solidity
SpecmanE
Spice
Sql
SRecode
Stata
Stratego
Svelte
Svg
Swift
Swig
SystemVerilog
Slint
Tact
Tcl
Templ
Tex
Text
Thrift
Toml
Tsx
Twig
TypeScript
UMPL
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
ZenCode
Zig
ZoKrates
Zsh
這可能是由於gcc生成.d文件。直到DEPOY決定不同的文件擴展名之前,您始終可以使用-e --exclude flag排除.d文件。
$ tokei . -e *.d
此存儲庫的規範來源託管在GitHub上。如果您有一個GitHub帳戶,請提出問題,並在此提取請求。
(c)Xampprocky和貢獻者的版權2015
有關貢獻者的完整列表,請參見圖。
Tokei是根據MIT許可證和Apache許可證(2.0版)的條款分發的。
有關更多信息,請參見許可證,許可-MIT。