fix clap deprecations

Run 'cargo check --features clap/deprecated' and fix all warnings
This commit is contained in:
klensy 2024-02-29 12:51:23 +03:00 committed by Yacin Tmimi
parent 21f353a637
commit 35c1b7d734
2 changed files with 6 additions and 7 deletions

View File

@ -61,7 +61,7 @@ pub struct Opts {
/// Options passed to rustfmt /// Options passed to rustfmt
// 'raw = true' to make `--` explicit. // 'raw = true' to make `--` explicit.
#[arg(name = "rustfmt_options", raw = true)] #[arg(id = "rustfmt_options", raw = true)]
rustfmt_options: Vec<String>, rustfmt_options: Vec<String>,
/// Format all packages, and also their local path-based dependencies /// Format all packages, and also their local path-based dependencies
@ -209,9 +209,8 @@ fn convert_message_format_to_rustfmt_args(
fn print_usage_to_stderr(reason: &str) { fn print_usage_to_stderr(reason: &str) {
eprintln!("{reason}"); eprintln!("{reason}");
let app = Opts::command(); let app = Opts::command();
app.after_help("") let help = app.after_help("").render_help();
.write_help(&mut io::stderr()) eprintln!("{help}");
.expect("failed to write to stderr");
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]

View File

@ -38,14 +38,14 @@ enum FormatDiffError {
} }
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[clap( #[command(
name = "rustfmt-format-diff", name = "rustfmt-format-diff",
disable_version_flag = true, disable_version_flag = true,
next_line_help = true next_line_help = true
)] )]
pub struct Opts { pub struct Opts {
/// Skip the smallest prefix containing NUMBER slashes /// Skip the smallest prefix containing NUMBER slashes
#[clap( #[arg(
short = 'p', short = 'p',
long = "skip-prefix", long = "skip-prefix",
value_name = "NUMBER", value_name = "NUMBER",
@ -54,7 +54,7 @@ pub struct Opts {
skip_prefix: u32, skip_prefix: u32,
/// Custom pattern selecting file paths to reformat /// Custom pattern selecting file paths to reformat
#[clap( #[arg(
short = 'f', short = 'f',
long = "filter", long = "filter",
value_name = "PATTERN", value_name = "PATTERN",