sort help output & group by functionality

This commit is contained in:
Lynne Megido 2022-02-18 14:36:50 +10:00
parent 2a0a74f775
commit b464ce8c08
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
2 changed files with 27 additions and 24 deletions

View File

@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## Unreleased
### Added
- When using the [`infer`] backend, fif is now able to detect [Mach-O](https://en.wikipedia.org/wiki/Mach-O) binaries
### Changed
- Help output is now sorted manually, and flags are grouped by functionality
### Other
- (@hannesbraun) Updated [`infer`] to v0.6.0 (!2)
- Update [`clap`] to v3.1.0, fixing deprecated code

View File

@ -63,21 +63,22 @@ 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
max_term_width = 120,
setting(clap::AppSettings::DeriveDisplayOrder)
)]
/// [`Clap`]-derived struct used to parse command line arguments.
pub struct Parameters {
/// Automatically rename files to use the correct extension, prompting the user for every rename.
#[clap(long)]
#[clap(long, help_heading = "RENAMING")]
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")]
#[clap(short = 'p', long, arg_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
/// overwrite files without prompting!
#[clap(long, requires = "fix")]
#[clap(long, requires = "fix", help_heading = "RENAMING")]
pub overwrite: bool,
// NOTE: it is impossible (as far as i can tell) to accept extensions with commas in their name. i don't know why
@ -86,7 +87,7 @@ pub struct Parameters {
/// 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)]
validator = validate_exts, help_heading = "FILTERING")]
pub exts: Option<Vec<StringType>>,
/// Use these preset lists of extensions as the search filter (comma-separated list).
@ -98,14 +99,14 @@ pub struct Parameters {
arg_enum,
use_value_delimiter = true,
require_value_delimiter = true,
value_name = "set"
value_name = "set", help_heading = "FILTERING"
)]
pub ext_set: Vec<ExtensionSet>,
/// 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 =
validate_exts)]
validate_exts, help_heading = "FILTERING")]
pub exclude: Option<Vec<StringType>>,
/// Exclude files using a preset list of extensions.
@ -116,63 +117,63 @@ pub struct Parameters {
arg_enum,
use_value_delimiter = true,
require_value_delimiter = true,
value_name = "set"
value_name = "set", help_heading = "FILTERING"
)]
pub exclude_set: Vec<ExtensionSet>,
/// Don't skip hidden files and directories.
/// Even if this flag is not present, fif will still recurse into a hidden root directory - for example, `fif
/// ~/.hidden` will recurse into `~/.hidden` regardless of whether or not -s was passed as an argument.
#[clap(short, long)]
#[clap(short, long, help_heading = "FILTERING")]
pub scan_hidden: bool,
/// Scan files without extensions.
/// By default, fif will ignore files without extensions - for example, a jpeg file named `photo` won't be considered
/// misnamed. Supplying the -S flag will cause fif to recommend renaming this file to `photo.jpg`.
#[clap(short = 'S', long)]
#[clap(short = 'S', long, help_heading = "FILTERING")]
pub scan_extensionless: bool,
/// Follow symlinks.
#[clap(short, long, help_heading = "FILTERING")]
pub follow_symlinks: bool,
/// Don't rename files with extensions unknown to fif.
/// For example, with this option, fif will not rename "image.unknown" to "image.jpg"
#[clap(short = 'I', long, help_heading = "FILTERING")]
pub ignore_unknown_exts: bool,
/// 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")]
#[clap(short, long, default_value = DEFAULT_FORMAT, arg_enum, value_name = "format", help_heading = "OUTPUT")]
pub output_format: OutputFormat,
/// Follow symlinks.
#[clap(short, long)]
pub follow_symlinks: bool,
/// Output verbosity. Each additional `-v` increases verbosity.
/// Can be overridden by FIF_LOG or RUST_LOG.
#[clap(short, long, parse(from_occurrences), group = "verbosity")]
#[clap(short, long, parse(from_occurrences), 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")]
#[clap(short, long, parse(from_occurrences), group = "verbosity", help_heading = "OUTPUT")]
pub quiet: u8,
/// Use canonical (absolute) paths in output.
/// A canonical path is the "one true path" to a given file, and is always an absolute path. While a file may have
/// many absolute paths (for example, on Windows, '\\?\C:\file.txt' and 'C:\file.txt' are both absolute paths to the
/// same file), but only one canonical path. This does not effect logged output.
#[clap(long)]
#[clap(long, help_heading = "OUTPUT")]
pub canonical_paths: bool,
/// The directory to process.
#[clap(name = "DIR", default_value = ".", parse(from_os_str))]
pub dir: PathBuf,
/// Don't rename files with extensions unknown to fif.
/// For example, with this option, fif will not rename "image.unknown" to "image.jpg"
#[clap(short = 'I', long)]
pub ignore_unknown_exts: bool,
#[cfg(feature = "multi-threaded")]
/// Number of jobs (threads) to use when scanning results.
/// The default behaviour is to use one thread per CPU thread. This behaviour can be manually requested by setting
/// `-j 0`. Using `-j 1` will disable multi-threading behaviour, as if you had compiled fif with the multi-threading
/// feature disabled. Setting more jobs than you have CPU threads is not recommended.
#[clap(short = 'j', long, default_value = "0")]
#[clap(short = 'j', long, default_value = "0", help_heading = "MISC")]
pub jobs: usize,
}