A collection of cargo subcommands for use while working on Rust source code and projects. This repository and package aims to make it easy to install all the additional commands at once.
You can install all of the subcommands included in cargo-extras with a single cargo install run.
$ cargo install cargo-extras
To see all the commands installed:
$ cargo --list
This may require a nightly version of cargo if you get an error about the install command not being found. If you are using multirust1,2 you could run:
$ multirust run nightly cargo install cargo-extras
You may also, instead compile and install the traditional way by following the instructions below.
Follow these instructions to compile cargo-extras, then skip down to Installation.
cargo and Rust installed$ git clone --depth 50 https://github.com/kbknapp/cargo-extras && cd cargo-extras$ cargo build --release (NOTE: There is a large performance differnce when compiling without optimizations, so I recommend alwasy using --release to enable to them)target/release/All you need to do is place the binary subcommands somewhere in your $PATH. Then run cargo <command> anywhere in your project directory. Example:
$ cp target/release/cargo-* ~/.bin
In the above example, the .bin directory inside my home directy is inside my $PATH
You 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
Option 1
If you have write permission to a directory listed in your $PATH or you have root permission (or via sudo), simply copy the binaries $ cp target/release/cargo-* to that directory # sudo cp target/release/cargo-* /usr/local/bin
Option 2
If 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 the binaries there.
Simply 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)
$ mkdir ~/bin
$ echo "export PATH=$PATH:$HOME/bin" >> ~/.bashrc
$ cp target/release/cargo-* ~/bin
$ source ~/.bashrc
On Windows 7/8 you can add directory to the PATH variable by opening a command line as an administrator and running
sh
C:\> setx path "%path%;C:\path\to\cargo\binaries"
Otherwise, ensure you have the binaries 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).
cargo-extras currently includes the following subcommands
cargo rustc -- -Zno-trans which can be helpful for running a faster compile if you only need correctness checkscargo commands in a rowcargodot and is an updated fork of cargo-dot with additional features$EDITORcargo to compile projects when sources changecargo-extras is released under the terms of the MIT. See the LICENSE-MIT file for the details. The subcommands themselves may be released under different licenes, see the src and the binary in question, most commands have a licenese file included with them.