rename videos set to video, multiple exts can be specified with multiple -e
flags
This commit is contained in:
parent
22f1f280d7
commit
d578efa7a4
3 changed files with 29 additions and 18 deletions
|
@ -7,9 +7,12 @@ Dates are given in YYYY-MM-DD format.
|
|||
- Added `-x`/`--exclude` flag for excluding file extensions (overrides `-e` or `-E` - `-E images -x jpg` scans all image
|
||||
files, except ".jpg" files)
|
||||
- Added `-X`/`--exclude-set` flag for excluding sets of files (like `-E`)
|
||||
- Both `-x` and `-e` can now be used like `-e jpg -e png` in addition to the existing `-e jpg,png` format
|
||||
#### Other
|
||||
- Published my fork of ['mime_guess'] as ['new_mime_guess'], allowing it to be used properly with
|
||||
[crates.io](https://crates.io)
|
||||
- The `videos` extension set has been renamed to `video`, in line with `audio`. `fif --help` has actually mistakenly
|
||||
referred to the set as `video` since v0.2.12! 0uo
|
||||
|
||||
### v0.2.13 (2021-04-26)
|
||||
#### Features
|
||||
|
|
|
@ -40,22 +40,30 @@ pub enum OutputFormat {
|
|||
setting(AppSettings::ColoredHelp)
|
||||
)]
|
||||
pub struct Parameters {
|
||||
/// Only examine files with these extensions (comma-separated list).
|
||||
/// This argument conflicts with `-E`.
|
||||
#[clap(short, long, use_delimiter = true, require_delimiter = true, group = "extensions")]
|
||||
// NOTE: clap's comma-separated argument parser makes it impossible to specify extensions with commas in their name -
|
||||
// `-e sil\,ly` is treated as ["sil", "ly"] rather than as ["silly"], no matter how i escape the comma (in bash,
|
||||
// anyway). is this really an issue? it does technically exclude some perfectly valid extensions, but i've never seen
|
||||
// a file extension with a comma in its name before.
|
||||
|
||||
/// 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_delimiter = true, takes_value = true)]
|
||||
pub exts: Option<Vec<StringType>>,
|
||||
|
||||
/// Use a preset list of extensions as the search filter.
|
||||
/// `media` includes all extensions from the `audio`, `video`, and `images` sets. This argument conflicts with `-e`.
|
||||
#[clap(short = 'E', long, arg_enum, group = "extensions")]
|
||||
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||
/// `media` includes all extensions from the `audio`, `video`, and `images` sets, making `-E media` equivalent to
|
||||
/// `-E audio,video,images`.
|
||||
#[clap(short = 'E', long, arg_enum)]
|
||||
pub ext_set: Option<ExtensionSet>,
|
||||
|
||||
/// Don't scan files with these extensions (comma-separated list).
|
||||
/// This option takes preference over files specified with -e or -E.
|
||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true)]
|
||||
/// Don't scan files with these extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'x', long, use_delimiter = true)]
|
||||
pub exclude: Option<Vec<StringType>>,
|
||||
|
||||
/// Exclude files using a preset list of extensions.
|
||||
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||
#[clap(short = 'X', long, arg_enum)]
|
||||
pub exclude_set: Option<ExtensionSet>,
|
||||
|
||||
|
@ -186,7 +194,7 @@ pub enum ExtensionSet {
|
|||
/// Extensions used for audio file formats, such as `mp3`, `ogg`, `flac`, etc.
|
||||
Audio,
|
||||
/// Extensions used for video file formats, such as `mkv`, `mp4`, `mov`, etc.
|
||||
Videos,
|
||||
Video,
|
||||
/// Extensions used for media file formats. This acts as a combination of the [Images](ExtensionSet::Images),
|
||||
/// [Audio](ExtensionSet::Audio) and [Videos](ExtensionSet::Videos) variants.
|
||||
Media,
|
||||
|
@ -206,11 +214,11 @@ impl ExtensionSet {
|
|||
match self {
|
||||
Self::Images => mime_guess::get_mime_extensions_str("image/*").unwrap().to_vec(),
|
||||
Self::Audio => mime_guess::get_mime_extensions_str("audio/*").unwrap().to_vec(),
|
||||
Self::Videos => mime_guess::get_mime_extensions_str("video/*").unwrap().to_vec(),
|
||||
Self::Video => mime_guess::get_mime_extensions_str("video/*").unwrap().to_vec(),
|
||||
Self::Media => [
|
||||
Self::Images.extensions(),
|
||||
Self::Audio.extensions(),
|
||||
Self::Videos.extensions(),
|
||||
Self::Video.extensions(),
|
||||
]
|
||||
.concat(),
|
||||
Self::Documents => vec![
|
||||
|
|
|
@ -247,14 +247,14 @@ fn exclude_set_overrides_includes() {
|
|||
#[test]
|
||||
/// Ensure the `exclude_set` flag (`-X`) overrides `-E`.
|
||||
fn exclude_set_overrides_include_set() {
|
||||
// pass `-E media` and `-X images` -- which should produce the equivalent of `-E audio,videos`
|
||||
// pass `-E media` and `-X images` -- which should produce the equivalent of `-E audio,video`
|
||||
let args: Parameters = Parameters::parse_from(vec!["fif", "-E", "media", "-X", "images"]);
|
||||
let extensions = args.extensions();
|
||||
assert!(extensions.is_some(), "Extensions should be set!");
|
||||
let extensions = extensions.unwrap();
|
||||
|
||||
// ensure all of audio and video's extensions are here
|
||||
for &ext in ExtensionSet::Audio.extensions().iter().chain(ExtensionSet::Videos.extensions().iter()) {
|
||||
for &ext in ExtensionSet::Audio.extensions().iter().chain(ExtensionSet::Video.extensions().iter()) {
|
||||
assert!(extensions.contains(&ext), "Extensions should contain {}!", ext)
|
||||
}
|
||||
|
||||
|
@ -274,8 +274,8 @@ fn rejects_bad_args() {
|
|||
vec!["fif", "-E"],
|
||||
// `-E` with an invalid set:
|
||||
vec!["fif", "-E", "pebis"],
|
||||
// `-E` and `-e`:
|
||||
vec!["fif", "-E", "media", "-e", "jpg"],
|
||||
// `-X` with an invalid set:
|
||||
vec!["fif", "-X", "pebis"],
|
||||
// `-e` with nothing but commas:
|
||||
vec!["fif", "-e", ",,,,,"],
|
||||
];
|
||||
|
@ -341,11 +341,11 @@ fn outputs_move_commands() {
|
|||
#[test]
|
||||
/// Ensure that the Media extension set contains all (is a superset) of Audio, Video, and Images.
|
||||
fn media_contains_audio_video_images() {
|
||||
use crate::parameters::ExtensionSet::{Audio, Images, Media, Videos};
|
||||
use crate::parameters::ExtensionSet::{Audio, Images, Media, Video};
|
||||
let media_exts = Media.extensions();
|
||||
|
||||
// assert every extension in the audio/video/image sets is contained in the media set
|
||||
[Audio.extensions(), Videos.extensions(), Images.extensions()]
|
||||
[Audio.extensions(), Video.extensions(), Images.extensions()]
|
||||
.concat()
|
||||
.into_iter()
|
||||
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
||||
|
|
Loading…
Reference in a new issue