Tokei 是一个使用 Rust 语言开发的显示代码统计信息的程序。Tokei 将显示文件的数量、这些文件中的总行数以及按语言分组的代码、注释和空格。
https://github.com/XAMPPRocky/tokei
特征:
Tokei 非常快,并且能够在几秒钟内计算数百万行代码。
Tokei 是准确的,Tokei 正确处理多行评论,嵌套评论,并且不计算字符串中的注释。提供准确的代码统计信息。
Tokei 具有大量的语言,支持150多种语言及其各种语言。
Tokei 可以以多种格式(CBOR,JSON,YAML)输出,从而使 Tokei 的输出易于存储和重复使用。这些也可以在将上一个运行的统计数据与另一组组合结合的托基中重复使用。
Tokei 可在 Mac,Linux 和 Windows 上使用。
Tokei 也是一个库,允许您轻松地将其与其他项目集成。
Tokei 带来和没有颜色。将 ENV 变量 no_color 设置为 1,它将是黑色和白色。
案例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 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 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
安装:
Linux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
MacOS
1 2 3 4 5 |
# Homebrew brew install tokei # MacPorts sudo port selfupdate sudo port install tokei |
Windows
1 |
scoop install tokei |
二进制文件下载
https://github.com/XAMPPRocky/tokei/releases
编译安装
1 |
cargo install --git https://github.com/XAMPPRocky/tokei.git tokei |
配置:
Tokei 有一个配置文件,允许您更改默认行为。该文件可以命名为 tokei.toml 或 .tokeirc。当前版本的 tokei 在三个不同的地方查找此文件。当前目录、主目录和配置目录。
使用:
基本用法
这是使用 tokei 的基本方法。它将报告 ./foo 和所有子文件夹中的代码。
1 |
tokei ./foo |
多文件夹
要让 tokei 在同一个调用中报告多个文件夹,只需添加一个逗号,或在另一个路径后面添加一个空格。
1 |
tokei ./foo ./bar ./baz |
1 |
tokei ./foo, ./bar, ./baz |
排除文件夹
Tokei 将遵循所有 .gitignore 和 .ignore 文件,您可以使用 –exclude 选项排除任何其他文件。–exclude 选项与 .gitignore 具有相同的语义。
1 |
tokei ./foo --exclude *.rs |
要排除的路径也可以在 .tokeignore 文件中列出,使用与 .gitignore 文件相同的语法。
排序输出
默认情况下,Tokei 按语言名称的字母顺序排序,但是使用 –sort 选项 tokei 也可以按任何列排序。
1 2 3 |
# blanks, code, comments, lines tokei ./foo --sort code |
输出文件统计信息
默认情况下,tokei 只输出语言总数,并且使用 –files 选项 tokei 也可以输出单个文件的统计信息。
1 |
tokei ./foo --files |
输出为不同格式
Tokei 通常输出为一种为终端设计的良好的可读格式。还使用了 –output 选项,可以使用各种其他格式,这些格式对于将数据引入另一个程序更有用。
注意:这个版本的 tokei 编译时没有任何序列化格式,要启用序列化,请使用 features 标志重新安装 tokei。
1 2 3 4 5 6 7 8 |
ALL: cargo install tokei --features all CBOR: cargo install tokei --features cbor YAML: cargo install tokei --features yaml |
当前支持的格式
JSON –output json
YAML –output yaml
CBOR –output cbor
1 |
tokei ./foo --output json |
以存储格式读取
Tokei 还可以将先前结果中添加的输出格式接收到当前运行中。Tokei 可以获取文件路径、作为选项值传递的格式,也可以从 stdin 获取。
1 |
tokei ./foo --input ./stats.json |
选项:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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. |
支持编程语言:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
Abap ActionScript Ada Agda Alex Alloy Asn1 Asp AspNet Assembly AssemblyGAS ATS Autoconf AutoHotKey Automake AWK 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 Factor FEN Fish FlatBuffers Forth FortranLegacy FortranModern FreeMarker FSharp Fstar GDB GdScript Gherkin Gleam Glsl Go Graphql Groovy Gwion 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 Mlatu 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 |
转载请注明:站长资源站 » Tokei 显示代码统计数据的程序