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
|
- Added `-x`/`--exclude` flag for excluding file extensions (overrides `-e` or `-E` - `-E images -x jpg` scans all image
|
||||||
files, except ".jpg" files)
|
files, except ".jpg" files)
|
||||||
- Added `-X`/`--exclude-set` flag for excluding sets of files (like `-E`)
|
- 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
|
#### Other
|
||||||
- Published my fork of ['mime_guess'] as ['new_mime_guess'], allowing it to be used properly with
|
- Published my fork of ['mime_guess'] as ['new_mime_guess'], allowing it to be used properly with
|
||||||
[crates.io](https://crates.io)
|
[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)
|
### v0.2.13 (2021-04-26)
|
||||||
#### Features
|
#### Features
|
||||||
|
|
|
@ -40,22 +40,30 @@ pub enum OutputFormat {
|
||||||
setting(AppSettings::ColoredHelp)
|
setting(AppSettings::ColoredHelp)
|
||||||
)]
|
)]
|
||||||
pub struct Parameters {
|
pub struct Parameters {
|
||||||
/// Only examine files with these extensions (comma-separated list).
|
// NOTE: clap's comma-separated argument parser makes it impossible to specify extensions with commas in their name -
|
||||||
/// This argument conflicts with `-E`.
|
// `-e sil\,ly` is treated as ["sil", "ly"] rather than as ["silly"], no matter how i escape the comma (in bash,
|
||||||
#[clap(short, long, use_delimiter = true, require_delimiter = true, group = "extensions")]
|
// 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>>,
|
pub exts: Option<Vec<StringType>>,
|
||||||
|
|
||||||
/// Use a preset list of extensions as the search filter.
|
/// Use these preset lists of extensions as the search filter (comma-separated list).
|
||||||
/// `media` includes all extensions from the `audio`, `video`, and `images` sets. This argument conflicts with `-e`.
|
/// `media` includes all extensions from the `audio`, `video`, and `images` sets, making `-E media` equivalent to
|
||||||
#[clap(short = 'E', long, arg_enum, group = "extensions")]
|
/// `-E audio,video,images`.
|
||||||
|
#[clap(short = 'E', long, arg_enum)]
|
||||||
pub ext_set: Option<ExtensionSet>,
|
pub ext_set: Option<ExtensionSet>,
|
||||||
|
|
||||||
/// Don't scan files with these extensions (comma-separated list).
|
/// Don't scan files with these extensions.
|
||||||
/// This option takes preference over files specified with -e or -E.
|
/// This option takes precedence over extensions specified with `-e` or `-E`.
|
||||||
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true)]
|
#[clap(short = 'x', long, use_delimiter = true)]
|
||||||
pub exclude: Option<Vec<StringType>>,
|
pub exclude: Option<Vec<StringType>>,
|
||||||
|
|
||||||
/// Exclude files using a preset list of extensions.
|
/// 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)]
|
#[clap(short = 'X', long, arg_enum)]
|
||||||
pub exclude_set: Option<ExtensionSet>,
|
pub exclude_set: Option<ExtensionSet>,
|
||||||
|
|
||||||
|
@ -186,7 +194,7 @@ pub enum ExtensionSet {
|
||||||
/// Extensions used for audio file formats, such as `mp3`, `ogg`, `flac`, etc.
|
/// Extensions used for audio file formats, such as `mp3`, `ogg`, `flac`, etc.
|
||||||
Audio,
|
Audio,
|
||||||
/// Extensions used for video file formats, such as `mkv`, `mp4`, `mov`, etc.
|
/// 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),
|
/// Extensions used for media file formats. This acts as a combination of the [Images](ExtensionSet::Images),
|
||||||
/// [Audio](ExtensionSet::Audio) and [Videos](ExtensionSet::Videos) variants.
|
/// [Audio](ExtensionSet::Audio) and [Videos](ExtensionSet::Videos) variants.
|
||||||
Media,
|
Media,
|
||||||
|
@ -206,11 +214,11 @@ impl ExtensionSet {
|
||||||
match self {
|
match self {
|
||||||
Self::Images => mime_guess::get_mime_extensions_str("image/*").unwrap().to_vec(),
|
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::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::Media => [
|
||||||
Self::Images.extensions(),
|
Self::Images.extensions(),
|
||||||
Self::Audio.extensions(),
|
Self::Audio.extensions(),
|
||||||
Self::Videos.extensions(),
|
Self::Video.extensions(),
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
Self::Documents => vec![
|
Self::Documents => vec![
|
||||||
|
|
|
@ -247,14 +247,14 @@ fn exclude_set_overrides_includes() {
|
||||||
#[test]
|
#[test]
|
||||||
/// Ensure the `exclude_set` flag (`-X`) overrides `-E`.
|
/// Ensure the `exclude_set` flag (`-X`) overrides `-E`.
|
||||||
fn exclude_set_overrides_include_set() {
|
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 args: Parameters = Parameters::parse_from(vec!["fif", "-E", "media", "-X", "images"]);
|
||||||
let extensions = args.extensions();
|
let extensions = args.extensions();
|
||||||
assert!(extensions.is_some(), "Extensions should be set!");
|
assert!(extensions.is_some(), "Extensions should be set!");
|
||||||
let extensions = extensions.unwrap();
|
let extensions = extensions.unwrap();
|
||||||
|
|
||||||
// ensure all of audio and video's extensions are here
|
// 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)
|
assert!(extensions.contains(&ext), "Extensions should contain {}!", ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,8 +274,8 @@ fn rejects_bad_args() {
|
||||||
vec!["fif", "-E"],
|
vec!["fif", "-E"],
|
||||||
// `-E` with an invalid set:
|
// `-E` with an invalid set:
|
||||||
vec!["fif", "-E", "pebis"],
|
vec!["fif", "-E", "pebis"],
|
||||||
// `-E` and `-e`:
|
// `-X` with an invalid set:
|
||||||
vec!["fif", "-E", "media", "-e", "jpg"],
|
vec!["fif", "-X", "pebis"],
|
||||||
// `-e` with nothing but commas:
|
// `-e` with nothing but commas:
|
||||||
vec!["fif", "-e", ",,,,,"],
|
vec!["fif", "-e", ",,,,,"],
|
||||||
];
|
];
|
||||||
|
@ -341,11 +341,11 @@ fn outputs_move_commands() {
|
||||||
#[test]
|
#[test]
|
||||||
/// Ensure that the Media extension set contains all (is a superset) of Audio, Video, and Images.
|
/// Ensure that the Media extension set contains all (is a superset) of Audio, Video, and Images.
|
||||||
fn media_contains_audio_video_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();
|
let media_exts = Media.extensions();
|
||||||
|
|
||||||
// assert every extension in the audio/video/image sets is contained in the media set
|
// 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()
|
.concat()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
.for_each(|ext| assert!(media_exts.contains(&ext)));
|
||||||
|
|
Loading…
Reference in a new issue