Skip to content

Commit

Permalink
Fix issue where cargo fmt --version would not display version info
Browse files Browse the repository at this point in the history
Fixes 5395

In PR 5239 we switched from using `structopt` to `clap`. It seems that
the default behavior for `clap` is to override the `--version` flag,
which prevented our custom version display code from running.

The fix as outlined in clap-rs/clap#3405 was
to set `#[clap(global_setting(AppSettings::NoAutoVersion))]` to prevent
clap from setting its own default behavior for the `--version` flag.
  • Loading branch information
ytmimi authored and calebcartwright committed Jun 22, 2022
1 parent a187091 commit 08105e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cargo-fmt/main.rs
Expand Up @@ -14,14 +14,15 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;

use clap::{CommandFactory, Parser};
use clap::{AppSettings, CommandFactory, Parser};

#[path = "test/mod.rs"]
#[cfg(test)]
mod cargo_fmt_tests;

#[derive(Parser)]
#[clap(
global_setting(AppSettings::NoAutoVersion),
bin_name = "cargo fmt",
about = "This utility formats all bin and lib files of \
the current crate using rustfmt."
Expand Down

0 comments on commit 08105e8

Please sign in to comment.