Crates.io | cargo-list |
lib.rs | cargo-list |
version | |
source | src |
created_at | 2023-05-13 17:56:52.574677 |
updated_at | 2024-12-05 18:15:06.278876 |
description | List and update installed crates |
homepage | |
repository | https://github.com/qtfkwk/cargo-list |
max_upload_size | |
id | 863842 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
$ cargo list -h
List and update installed crates
Usage: cargo list [OPTIONS] [PATTERN]...
Arguments:
[PATTERN]... List/update crates matching given pattern(s)
Options:
-f <FORMAT> Output format [default: md] [possible values: json,
json-pretty, md, rust, rust-pretty]
-k <KIND> Kind(s) [default: external] [possible values: local, git,
external]
-a All kinds
-o, --outdated Hide up-to-date crates
-I Ignore version requirements
-R Consider a crate to be outdated if compiled with a Rust
version different than the active toolchain
-u, --update Update outdated crates
-n, --dry-run Dry run
-c <PATH> Cargo install metadata file [default: ~/.cargo/.crates2.json]
-r, --readme Print readme
-h, --help Print help
-V, --version Print version
$ cargo list -V
cargo-list 0.27.0
cargo list
cargo
cargo list cargo
cargo
cargo list ^cargo
list
cargo list 'list$'
cargo-list
cargo list '^cargo-list$'
cargo list -o
cargo list -ou
cargo install
commands to update outdated external cratescargo list -oun
cargo list -oI
cargo list -oR
cargo list -oIRu
cargo list -k git
cargo list -k local
cargo list -k local -k git -k external
or shorter:
cargo list -a
cargo list -k git -o
cargo list -k local -o
cargo list -k local -k git -k external -o
or shorter:
cargo list -ao
cargo list -f json
cargo list -f json-pretty
cargo list -f rust
cargo list -f rust-pretty
cargo list -f json -o
cargo list -f json-pretty -o
cargo list -f rust -o
cargo list -f rust-pretty -o
use cargo_list::Crates;
use expanduser::expanduser;
use rayon::prelude::*;
use std::collections::BTreeMap;
let path = expanduser("~/.cargo/.crates2.json").unwrap();
match Crates::from(&path) {
Ok(installed) => {
if installed.is_empty() {
println!("No crates installed!");
} else {
let all = installed.crates();
let outdated = all
.par_iter()
.filter_map(|(&name, &c)| c.outdated.then_some((name, c)))
.collect::<BTreeMap<_, _>>();
if outdated.is_empty() {
// List all crates in CSV
println!("Name,Installed");
for (name, c) in &all {
println!("{name},{}", c.installed);
}
} else {
// List outdated crates in CSV
println!("Name,Installed,Available");
for (name, c) in &outdated {
println!("{name},{},{}", c.installed, c.available);
}
// Print the `cargo install` commands for outdated crates
// for command in outdated
// .iter()
// .map(|(_name, c)| c.update_command().join(" "))
// {
// println!("{command}");
// }
// Update outdated crates
// outdated.iter().for_each(|(_name, c)| c.update());
}
}
}
Err(e) => {
eprintln!("Error: {e}");
}
}
If you want to include just a subset of the crates, instead of Crates::from(&path)
, use
Crates::from_include(&path, &patterns)
where patterns
is a slice of &str
regex
patterns.
Please read the CHANGELOG.md
in the repository.