From 5fd34e6678dc972e5e4b5ed3ac89bf3395baa596 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:03:13 -0700 Subject: [PATCH] Print a version with `--version` (#665) --- CHANGELOG.md | 2 ++ Cargo.toml | 10 ++++++++-- cargo-insta/src/cli.rs | 4 +--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f78e15..3849ca80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ All notable changes to insta and cargo-insta are documented here. - Warnings are printed when any snapshot uses a legacy format. #599 +- `cargo insta --version` now prints a version. #665 + - `insta` now internally uses `INSTA_UPDATE=force` rather than `INSTA_FORCE_UPDATE=1`. (This doesn't affect users of `cargo-insta`, which handles this internally.) #482 diff --git a/Cargo.toml b/Cargo.toml index 7164d075..50d664d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,13 @@ install-updater = false installers = ["shell", "powershell"] pr-run-mode = "plan" precise-builds = true -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +targets = [ + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", + "x86_64-pc-windows-msvc", +] [profile.dist] inherits = "release" @@ -17,4 +23,4 @@ lto = "thin" [workspace.dependencies] # Needs pinning in Cargo.lock because of MSRV -clap = {version = "4.1", features = ["derive", "env"]} +clap = { version = "4.1", features = ["derive", "env"] } diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 661af6a4..6c71c567 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -28,9 +28,6 @@ use clap::{Args, Parser, Subcommand, ValueEnum}; #[command( bin_name = "cargo insta", arg_required_else_help = true, - // TODO: do we want these? - disable_colored_help = true, - disable_version_flag = true, next_line_help = true )] struct Opts { @@ -61,6 +58,7 @@ impl fmt::Display for ColorWhen { #[derive(Subcommand, Debug)] #[command( + version, after_help = "For the online documentation of the latest version, see https://insta.rs/docs/cli/." )] #[allow(clippy::large_enum_variant)]