update clap to 4.1

This commit is contained in:
Lynne Megido 2023-03-15 06:23:59 +10:00
parent 9e592863f1
commit 61196df626
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
3 changed files with 21 additions and 21 deletions

View File

@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## Unreleased
### Changed
- The Minimum Supported Rust Version (MSRV) is now **1.57.0**.
- The Minimum Supported Rust Version (MSRV) is now **1.64.0**.
- Update [`clap`] to v4.0
## v0.6.0 - 2022-09-04
### Changed

View File

@ -5,7 +5,7 @@ version = "0.6.0"
authors = ["Lynnesbian <lynne@bune.city>"]
edition = "2021"
license = "GPL-3.0-or-later"
rust-version = "1.57.0" # os_str_bytes requires >=1.57.0, numerous other deps require 2021 edition support
rust-version = "1.64.0" # clap 4.1 requires >=1.64.0
repository = "https://gitlab.com/Lynnesbian/fif"
readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"]
@ -49,7 +49,7 @@ xdg-mime = "0.3.3"
infer = { version = "0.13.0", optional = true }
[dependencies.clap]
version = "3.2"
version = "~4.1"
default-features = false
features = ["wrap_help", "color", "derive", "std", "unicode"]

View File

@ -7,7 +7,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf;
use cfg_if::cfg_if;
use clap::{ArgEnum, Parser};
use clap::{ValueEnum, Parser, ArgAction};
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
use crate::String as StringType;
@ -22,7 +22,7 @@ cfg_if! {
}
}
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
/// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format`
/// flag.
pub enum OutputFormat {
@ -39,7 +39,7 @@ pub enum OutputFormat {
Json,
}
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
/// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`.
/// Specified at runtime with the `-p`/`--prompt` flag.
pub enum Prompt {
@ -63,8 +63,7 @@ pub enum Prompt {
This program is free software: you can redistribute it and/or modify \
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 \
of the License, or (at your option) any later version.",
max_term_width = 120,
setting(clap::AppSettings::DeriveDisplayOrder)
max_term_width = 120
)]
/// [`Clap`]-derived struct used to parse command line arguments.
pub struct Parameters {
@ -73,7 +72,7 @@ pub struct Parameters {
pub fix: bool,
/// Requires --fix. Should fif prompt you `Never`, only on `Error`s and overwrites, or `Always`?
#[clap(short = 'p', long, arg_enum, requires = "fix", help_heading = "RENAMING")]
#[clap(short = 'p', long, value_enum, requires = "fix", help_heading = "RENAMING")]
pub prompt: Option<Prompt>,
/// Requires --fix. Allow overwriting files. Warning: When used in combination with `--prompt never`, fif will
@ -86,8 +85,8 @@ pub struct Parameters {
/// Only examine files with these extensions.
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
/// separating them with commas (`-e jpg,png,gif`).
#[clap(short, long, use_value_delimiter = true, require_value_delimiter = true, value_name = "ext", takes_value = true,
validator = validate_exts, help_heading = "FILTERING")]
#[clap(short, long, use_value_delimiter = true, value_delimiter = ',', value_name = "ext", num_args(1),
value_parser = validate_exts, help_heading = "FILTERING")]
pub exts: Option<Vec<StringType>>,
/// Use these preset lists of extensions as the search filter (comma-separated list).
@ -96,9 +95,9 @@ pub struct Parameters {
#[clap(
short = 'E',
long,
arg_enum,
value_enum,
use_value_delimiter = true,
require_value_delimiter = true,
value_delimiter = ',',
value_name = "set",
help_heading = "FILTERING"
)]
@ -106,7 +105,7 @@ pub struct Parameters {
/// Don't scan files with these extensions.
/// This option takes precedence over extensions specified with `-e` or `-E`.
#[clap(short = 'x', long, use_value_delimiter = true, require_value_delimiter = true, value_name = "ext", validator =
#[clap(short = 'x', long, use_value_delimiter = true, value_delimiter = ',', value_name = "ext", value_parser =
validate_exts, help_heading = "FILTERING")]
pub exclude: Option<Vec<StringType>>,
@ -115,9 +114,9 @@ pub struct Parameters {
#[clap(
short = 'X',
long,
arg_enum,
value_enum,
use_value_delimiter = true,
require_value_delimiter = true,
value_delimiter = ',',
value_name = "set",
help_heading = "FILTERING"
)]
@ -146,17 +145,17 @@ pub struct Parameters {
/// Output format to use.
/// By default, fif will output a PowerShell script on Windows, and a Bourne Shell script on other platforms.
#[clap(short, long, default_value = DEFAULT_FORMAT, arg_enum, value_name = "format", help_heading = "OUTPUT")]
#[clap(short, long, default_value = DEFAULT_FORMAT, value_enum, value_name = "format", help_heading = "OUTPUT")]
pub output_format: OutputFormat,
/// Output verbosity. Each additional `-v` increases verbosity.
/// Can be overridden by FIF_LOG or RUST_LOG.
#[clap(short, long, parse(from_occurrences), group = "verbosity", help_heading = "OUTPUT")]
#[clap(short, long, action = ArgAction::Count, group = "verbosity", help_heading = "OUTPUT")]
pub verbose: u8,
/// Output quietness. Each additional `-q` decreases verbosity.
/// Can be overridden by FIF_LOG or RUST_LOG.
#[clap(short, long, parse(from_occurrences), group = "verbosity", help_heading = "OUTPUT")]
#[clap(short, long, action = ArgAction::Count, group = "verbosity", help_heading = "OUTPUT")]
pub quiet: u8,
/// Use canonical (absolute) paths in output.
@ -167,7 +166,7 @@ pub struct Parameters {
pub canonical_paths: bool,
/// The directory to process.
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
#[clap(name = "DIR", default_value = ".", value_parser)]
pub dir: PathBuf,
#[cfg(feature = "multi-threaded")]
@ -298,7 +297,7 @@ impl Parameters {
}
/// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag.
#[derive(ArgEnum, Eq, PartialEq, Debug, Copy, Clone)]
#[derive(ValueEnum, Eq, PartialEq, Debug, Copy, Clone)]
pub enum ExtensionSet {
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
Images,