Crates.io | e_crate_version_checker |
lib.rs | e_crate_version_checker |
version | |
source | src |
created_at | 2025-03-15 03:52:05.908473+00 |
updated_at | 2025-04-20 23:59:42.064821+00 |
description | A tool to check for newer versions of Rust crates on crates.io and interactively update them. |
homepage | |
repository | |
max_upload_size | |
id | 1593174 |
Cargo.toml error: | TOML parse error at line 20, column 1 | 20 | 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 |
e_crate_version_checker
is a Rust library and command-line application that checks for new versions of a specified crate from crates.io and optionally updates it using cargo install
. The tool supports simple numeric version comparisons. It also provides an interactive upgrade prompt for improved usability.
Version Checking:
Query crates.io to retrieve the latest version of a crate and compare it with the currently installed version.
Interactive Update:
Provides an interactive prompt that asks the user if they want to update a crate when a new version is available.
Flexible Configuration:
Supports enabling/disabling features such as check-version
, uses_reqwest
, and uses_serde
to tailor the functionality to your needs.
Fortune:
When the fortune
feature is enabled, displays a random developer “fortune” before the update prompt.
Changelog:
When the changelog
feature is enabled, embeds and displays the latest release notes from the parent crate’s CHANGELOG after a successful update.
To use this crate in your project, add the following to your Cargo.toml
:
[dependencies]
e_crate_version_checker = "0.1.0"
Make sure to enable the features you need. For example:
[dependencies.e_crate_version_checker]
version = "0.1.0"
features = ["check-version", "uses_reqwest", "uses_serde", "fortune", "changelog"]
You can use the version checking functions directly in your Rust code. For example:
use e_crate_version_checker::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// required : register the current crate in the User-Agent string.
register_user_crate!();
let crate_name = "cargo-e";
let latest = get_latest_version(crate_name)?;
println!("Latest version: {}", latest);
if is_newer_version_available(env!("CARGO_PKG_VERSION"), crate_name)? {
println!("A new version is available!");
} else {
println!("You are running the latest version.");
}
// Alternatively, check for update with a single call.
check_for_update()?;
Ok(())
}
Build the project with Cargo:
cargo build --release
Run the application by passing the name of the crate you want to check:
./target/release/e_crate_version_checker <crate_name>
For example:
./target/release/e_crate_version_checker cargo-e
The application will print the current version, query crates.io for the latest version, and prompt you to update if a newer version is available.
The crate includes tests to verify update arguments, version‑checking logic, and changelog embedding. To run the full test suite:
cargo test --features changelog
You can drive the interactive prompt, fortunes, and changelog display locally without publishing or installing prior versions by using these environment variables:
E_CRATE_CURRENT_VERSION
Override the detected current version (e.g., simulate an old install).E_CRATE_DRY_RUN
Skip the actual cargo install
step (dry-run mode).E_CRATE_FORCE_INTERACTIVE
Bypass non-interactive detection so prompts always fire.e_crate_version_checker
printf "\ny\n" \
| E_CRATE_CURRENT_VERSION=0.0.1 \
E_CRATE_DRY_RUN=1 \
E_CRATE_FORCE_INTERACTIVE=1 \
cargo run --features changelog -- e_crate_version_checker
You should see output like:
minor update for e_crate_version_checker: 0.0.1 -> 0.1.15
want to install? [Yes/no] (wait 5 seconds)
Update complete (dry-run).
📜 Changelog for version 0.1.15:
### Other
- extended samples are now showing.
cargo-e
Integrationprintf "\ny\n" \
| E_CRATE_CURRENT_VERSION=0.1.0 \
E_CRATE_DRY_RUN=1 \
E_CRATE_FORCE_INTERACTIVE=1 \
cargo run --features fortune,changelog -- package-name
$Env:E_CRATE_CURRENT_VERSION='0.1.0'; `
$Env:E_CRATE_DRY_RUN='1'; `
$Env:E_CRATE_FORCE_INTERACTIVE='1'; `
'y' | cargo run --features fortune,changelog -- package-name
Replace package-name
with the crate you want to test. This will trigger fortunes and changelog display even for the default interactive_crate_upgrade
flow.
Contributions are welcome! Please fork the repository and open a pull request with your changes. When contributing, ensure that your code adheres to the existing style and that you update tests as necessary.
This project is licensed under the MIT License. See the LICENSE file for details.
Addendums come at the beginning of the sort order, yet they appear at the end?
Instead of “Addendums come at the beginning…”, consider “Addenda come at the beginning…” Rationale: “Addenda” is the traditional plural of “addendum.”
This e_crate_version_checker
is a standalone example of quality expected in simple projects. It's a library and its a executable. It can be run using cargo run
with no additional arguments. It has inline tests, I didn't feel like integration tests were needed as I was not feeling it tonight. cargo-e now has a mechanism to offer automatic upgrades. Is there dead code? Spelling mistakes? Commented code? What's it matter?
It departs from typical Cargo project conventions (examples
) by adopting the name addendum
, reflecting a HORNER convention — a set of personal practices you may choose to adopt or laugh at. It's also a project HEREDOC. If that's not clear now; follow along and it will be clear. This is example 2.
Conventions require examples. cargo-e uses examples to properly test its ideas. I communicate ideas with code and LLMs.
What even is "literate programming"? I didn't read it. I don't know if its worth your time. Tl;dr: if you want to preserve knowledge, then literate programming is a good fit.
Releasing software and qualifying software is not easy to do if you can't point to what "good enough" is. That's the problem. There isn't much to point at. I'm willing to be laughed at and make bad choices in naming things.
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton what name should i pick now?
Conventions are good. You should—um, add them? https://github.com/davehorner/mkcmt
-- Dave Horner 3/2025 HORNER EXAMPLE 2 sort order, field separators, and huh?