{"id":13636214,"url":"https://github.com/kbknapp/cargo-count","last_synced_at":"2025-04-19T04:32:19.930Z","repository":{"id":36799768,"uuid":"41106587","full_name":"kbknapp/cargo-count","owner":"kbknapp","description":"a cargo subcommand for counting lines of code in Rust projects","archived":true,"fork":false,"pushed_at":"2023-07-02T06:52:53.000Z","size":199,"stargazers_count":129,"open_issues_count":15,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-06T10:39:10.618Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbknapp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-08-20T16:25:05.000Z","updated_at":"2024-04-22T21:01:21.000Z","dependencies_parsed_at":"2024-01-14T19:15:01.287Z","dependency_job_id":"5806fe83-9233-46b1-b765-464988d231a9","html_url":"https://github.com/kbknapp/cargo-count","commit_stats":{"total_commits":64,"total_committers":9,"mean_commits":7.111111111111111,"dds":0.1875,"last_synced_commit":"eebe6f8772af5ca1add8a770fd1ac8bb4a4edec5"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbknapp%2Fcargo-count","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbknapp%2Fcargo-count/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbknapp%2Fcargo-count/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbknapp%2Fcargo-count/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbknapp","download_url":"https://codeload.github.com/kbknapp/cargo-count/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223790568,"owners_count":17203355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:00:58.625Z","updated_at":"2024-11-09T05:31:25.866Z","avatar_url":"https://github.com/kbknapp.png","language":"Rust","readme":"# cargo-count\n\n[![Join the chat at https://gitter.im/kbknapp/cargo-count](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kbknapp/cargo-count?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nLinux: [![Build Status](https://travis-ci.org/kbknapp/cargo-count.svg?branch=master)](https://travis-ci.org/kbknapp/cargo-count)\n\nA cargo subcommand for displaying line counts of source code in projects, including a niave `unsafe` counter for Rust source files. This subcommand was originally based off and inspired by the project [tokei](https://github.com/aaronepower/tokei) by [Aaronepower](https://github.com/aaronepower)\n\n## Demo\n\nTo count the source code in the [Rust](https://github.com/rust-lang/rust) repository (checkout `4c99649`), and print some naive statistics on how much \"unsafe\" code exists.\n\n**NOTE:** The Rust repository is quite large, if you're on a slow internet connect consider using a smaller repository, such as the `cargo-count` repo.\n\n```\n$ git clone https://github.com/rust-lang/rust\n$ cd rust\n$ cargo count --separator , --unsafe-statistics\nGathering information...\n         Language    Files  Lines    Blanks  Comments  Code     Unsafe (%)\n         --------    -----  -----    ------  --------  ----     ----------\n         Rust        6,018  528,510  66,984  133,698   327,792  3,163 (0.96%)\n         C           54     9,962    1,445   1,492     7,025    7,025 (100.00%)\n         CSS         4      1,266    149     52        1,065    \n         JavaScript  4      1,118    131     166       821      \n         Python      31     4,797    843     585       3,369    \n         C Header    13     1,865    284     585       996      996 (100.00%)\n         C++         4      1,611    185     81        1,345    1,345 (100.00%)\n         --------    -----  -----    ------  --------  ----     ----------\nTotals:              6,128  549,129  70,021  136,659   342,413  12,529 (3.66%)\n\n```\n\nThe `--separator ,` sets a `,` character as the thousands separator, and `--unsafe-statistics` looks for, and counts lines of `unsafe`.\n\n## Installing\n\n`cargo-count` can be installed with `cargo install`\n\n```\n$ cargo install cargo-count\n```\n\nThis may require a nightly version of `cargo` if you get an error about the `install` command not being found. You may also compile and install the traditional way by followin the instructions below.\n\n\n## Compiling\n\nFollow these instructions to compile `cargo-count`, then skip down to Installation.\n\n 1. Ensure you have current version of `cargo` and [Rust](https://www.rust-lang.org) installed\n 2. Clone the project `$ git clone https://github.com/kbknapp/cargo-count \u0026\u0026 cd cargo-count`\n 3. Build the project `$ cargo build --release` (**NOTE:** There is a large performance differnce when compiling without optimizations, so I recommend alwasy using `--release` to enable to them)\n 4. Once complete, the binary will be located at `target/release/cargo-count`\n\n## Installation and Usage\n\nAll you need to do is place `cargo-count` somewhere in your `$PATH`. Then run `cargo count` anywhere in your project directory. For full details see below.\n\n### Linux / OS X\n\nYou have two options, place `cargo-count` into a directory that is already located in your `$PATH` variable (To see which directories those are, open a terminal and type `echo \"${PATH//:/\\n}\"`, the quotation marks are important), or you can add a custom directory to your `$PATH`\n\n**Option 1**\nIf you have write permission to a directory listed in your `$PATH` or you have root permission (or via `sudo`), simply copy the `cargo-count` to that directory `# sudo cp cargo-count /usr/local/bin`\n\n**Option 2**\nIf you do not have root, `sudo`, or write permission to any directory already in `$PATH` you can create a directory inside your home directory, and add that. Many people use `$HOME/.bin` to keep it hidden (and not clutter your home directory), or `$HOME/bin` if you want it to be always visible. Here is an example to make the directory, add it to `$PATH`, and copy `cargo-count` there.\n\nSimply change `bin` to whatever you'd like to name the directory, and `.bashrc` to whatever your shell startup file is (usually `.bashrc`, `.bash_profile`, or `.zshrc`)\n\n```sh\n$ mkdir ~/bin\n$ echo \"export PATH=$PATH:$HOME/bin\" \u003e\u003e ~/.bashrc\n$ cp cargo-count ~/bin\n$ source ~/.bashrc\n```\n\n### Windows\n\nOn Windows 7/8 you can add directory to the `PATH` variable by opening a command line as an administrator and running\n\n```sh\nC:\\\u003e setx path \"%path%;C:\\path\\to\\cargo-count\\binary\"\n```\n\nOtherwise, ensure you have the `cargo-count` binary in the directory which you operating in the command line from, because Windows automatically adds your current directory to PATH (i.e. if you open a command line to `C:\\my_project\\` to use `cargo-count` ensure `cargo-count.exe` is inside that directory as well).\n\n\n### Options\n\nThere are a few options for using `cargo-count` which should be somewhat self explanitory.\n\n```\nUSAGE:\n    cargo count [FLAGS] [OPTIONS] [--] [ARGS]\n\nFLAGS:\n    -S, --follow-symlinks      Follows symlinks and counts source files it finds\n    -a, --all                  Do not ignore .gitignored paths\n                               (Defaults to false when omitted)\n    -h, --help                 Prints help information\n        --unsafe-statistics    Displays lines and percentages of \"unsafe\" code\n    -V, --version              Prints version information\n    -v, --verbose              Print verbose output\n\nOPTIONS:\n    -l, --language \u003cexts\u003e...    Only count these languges (by source code extension)\n                                (i.e. '-l js py cpp')\n    -e, --exclude \u003cpaths\u003e...    Files or directories to exclude (automatically includes '.git')\n        --utf8-rule \u003crule\u003e      Sets the UTF-8 parsing rule (Defaults to 'strict')\n                                 [values: ignore lossy strict]\n    -s, --separator \u003csep\u003e       Set the thousands separator for pretty printing\n\nARGS:\n    to_count...    The files or directories (including children) to count\n                   (defaults to current working directory when omitted)\n\nWhen using '--exclude \u003cpath\u003e' the path given can either be relative to the current \ndirectory, or absolute. When '\u003cpath\u003e' is a file, it must be relative to the current \ndirectory or it will not be found. Example, if the current directory has a child \ndirectory named 'target' with a child fild 'test.rs' and you use `--exclude target/test.rs' \n\nGlobs are also supported. For example, to exclude 'test.rs' files from all child directories \nof the current directory you could do '--exclude */test.rs'.\n```\n\n## License\n\n`cargo-count` is released under the terms of the MIT. See the LICENSE-MIT file for the details.\n\n## Dependencies Tree\n![cargo-count dependencies](cargo-count.png)\n","funding_links":[],"categories":["Development tools"],"sub_categories":["Build system"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbknapp%2Fcargo-count","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbknapp%2Fcargo-count","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbknapp%2Fcargo-count/lists"}