update clap to 4.1
This commit is contained in:
parent
9e592863f1
commit
61196df626
3 changed files with 21 additions and 21 deletions
|
@ -6,7 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
### Changed
|
### 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
|
## v0.6.0 - 2022-09-04
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -5,7 +5,7 @@ version = "0.6.0"
|
||||||
authors = ["Lynnesbian <lynne@bune.city>"]
|
authors = ["Lynnesbian <lynne@bune.city>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0-or-later"
|
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"
|
repository = "https://gitlab.com/Lynnesbian/fif"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["mime", "mimetype", "utilities", "tools"]
|
keywords = ["mime", "mimetype", "utilities", "tools"]
|
||||||
|
@ -49,7 +49,7 @@ xdg-mime = "0.3.3"
|
||||||
infer = { version = "0.13.0", optional = true }
|
infer = { version = "0.13.0", optional = true }
|
||||||
|
|
||||||
[dependencies.clap]
|
[dependencies.clap]
|
||||||
version = "3.2"
|
version = "~4.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["wrap_help", "color", "derive", "std", "unicode"]
|
features = ["wrap_help", "color", "derive", "std", "unicode"]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::collections::BTreeSet;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use clap::{ArgEnum, Parser};
|
use clap::{ValueEnum, Parser, ArgAction};
|
||||||
|
|
||||||
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
|
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
|
||||||
use crate::String as StringType;
|
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`
|
/// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format`
|
||||||
/// flag.
|
/// flag.
|
||||||
pub enum OutputFormat {
|
pub enum OutputFormat {
|
||||||
|
@ -39,7 +39,7 @@ pub enum OutputFormat {
|
||||||
Json,
|
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`.
|
/// 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.
|
/// Specified at runtime with the `-p`/`--prompt` flag.
|
||||||
pub enum Prompt {
|
pub enum Prompt {
|
||||||
|
@ -63,8 +63,7 @@ pub enum Prompt {
|
||||||
This program is free software: you can redistribute it and/or modify \
|
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 \
|
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.",
|
of the License, or (at your option) any later version.",
|
||||||
max_term_width = 120,
|
max_term_width = 120
|
||||||
setting(clap::AppSettings::DeriveDisplayOrder)
|
|
||||||
)]
|
)]
|
||||||
/// [`Clap`]-derived struct used to parse command line arguments.
|
/// [`Clap`]-derived struct used to parse command line arguments.
|
||||||
pub struct Parameters {
|
pub struct Parameters {
|
||||||
|
@ -73,7 +72,7 @@ pub struct Parameters {
|
||||||
pub fix: bool,
|
pub fix: bool,
|
||||||
|
|
||||||
/// Requires --fix. Should fif prompt you `Never`, only on `Error`s and overwrites, or `Always`?
|
/// 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>,
|
pub prompt: Option<Prompt>,
|
||||||
|
|
||||||
/// Requires --fix. Allow overwriting files. Warning: When used in combination with `--prompt never`, fif will
|
/// 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.
|
/// 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
|
/// 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`).
|
/// 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,
|
#[clap(short, long, use_value_delimiter = true, value_delimiter = ',', value_name = "ext", num_args(1),
|
||||||
validator = validate_exts, help_heading = "FILTERING")]
|
value_parser = validate_exts, help_heading = "FILTERING")]
|
||||||
pub exts: Option<Vec<StringType>>,
|
pub exts: Option<Vec<StringType>>,
|
||||||
|
|
||||||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||||
|
@ -96,9 +95,9 @@ pub struct Parameters {
|
||||||
#[clap(
|
#[clap(
|
||||||
short = 'E',
|
short = 'E',
|
||||||
long,
|
long,
|
||||||
arg_enum,
|
value_enum,
|
||||||
use_value_delimiter = true,
|
use_value_delimiter = true,
|
||||||
require_value_delimiter = true,
|
value_delimiter = ',',
|
||||||
value_name = "set",
|
value_name = "set",
|
||||||
help_heading = "FILTERING"
|
help_heading = "FILTERING"
|
||||||
)]
|
)]
|
||||||
|
@ -106,7 +105,7 @@ pub struct Parameters {
|
||||||
|
|
||||||
/// Don't scan files with these extensions.
|
/// Don't scan files with these extensions.
|
||||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
/// 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")]
|
validate_exts, help_heading = "FILTERING")]
|
||||||
pub exclude: Option<Vec<StringType>>,
|
pub exclude: Option<Vec<StringType>>,
|
||||||
|
|
||||||
|
@ -115,9 +114,9 @@ pub struct Parameters {
|
||||||
#[clap(
|
#[clap(
|
||||||
short = 'X',
|
short = 'X',
|
||||||
long,
|
long,
|
||||||
arg_enum,
|
value_enum,
|
||||||
use_value_delimiter = true,
|
use_value_delimiter = true,
|
||||||
require_value_delimiter = true,
|
value_delimiter = ',',
|
||||||
value_name = "set",
|
value_name = "set",
|
||||||
help_heading = "FILTERING"
|
help_heading = "FILTERING"
|
||||||
)]
|
)]
|
||||||
|
@ -146,17 +145,17 @@ pub struct Parameters {
|
||||||
|
|
||||||
/// Output format to use.
|
/// Output format to use.
|
||||||
/// By default, fif will output a PowerShell script on Windows, and a Bourne Shell script on other platforms.
|
/// 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,
|
pub output_format: OutputFormat,
|
||||||
|
|
||||||
/// Output verbosity. Each additional `-v` increases verbosity.
|
/// Output verbosity. Each additional `-v` increases verbosity.
|
||||||
/// Can be overridden by FIF_LOG or RUST_LOG.
|
/// 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,
|
pub verbose: u8,
|
||||||
|
|
||||||
/// Output quietness. Each additional `-q` decreases verbosity.
|
/// Output quietness. Each additional `-q` decreases verbosity.
|
||||||
/// Can be overridden by FIF_LOG or RUST_LOG.
|
/// 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,
|
pub quiet: u8,
|
||||||
|
|
||||||
/// Use canonical (absolute) paths in output.
|
/// Use canonical (absolute) paths in output.
|
||||||
|
@ -167,7 +166,7 @@ pub struct Parameters {
|
||||||
pub canonical_paths: bool,
|
pub canonical_paths: bool,
|
||||||
|
|
||||||
/// The directory to process.
|
/// The directory to process.
|
||||||
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
|
#[clap(name = "DIR", default_value = ".", value_parser)]
|
||||||
pub dir: PathBuf,
|
pub dir: PathBuf,
|
||||||
|
|
||||||
#[cfg(feature = "multi-threaded")]
|
#[cfg(feature = "multi-threaded")]
|
||||||
|
@ -298,7 +297,7 @@ impl Parameters {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag.
|
/// 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 {
|
pub enum ExtensionSet {
|
||||||
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
|
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
|
||||||
Images,
|
Images,
|
||||||
|
|
Loading…
Reference in a new issue