Skip to content

Commit

Permalink
Replace skip-unsupported-extension option with no-skip-unsupported-ex…
Browse files Browse the repository at this point in the history
…tension flag
  • Loading branch information
Artanu authored and foresterre committed Jul 3, 2020
1 parent 284cafd commit 82afa32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ sic_parser = { version = "0.12.0", path = "components/sic_parser"}

anyhow = "1.0.31"
atty = "0.2.14"
boolean = "0.3.0"
clap = "2.32.0"
inflate = "0.4.5"
globwalk = "0.8.0"
Expand Down
15 changes: 6 additions & 9 deletions src/cli/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define_arg_consts!(arg_names, {
ARG_MODE,

// config for glob/batch mode
ARG_GLOB_SKIP_UNSUPPORTED_EXTENSIONS,
ARG_GLOB_NO_SKIP_UNSUPPORTED_EXTENSIONS,

// set specific configurations for decoding
ARG_SELECT_FRAME,
Expand Down Expand Up @@ -138,16 +138,13 @@ pub fn create_app(
)

// config for glob/batch mode
.arg(Arg::with_name(ARG_GLOB_SKIP_UNSUPPORTED_EXTENSIONS)
.long("skip-unsupported-extensions")
.takes_value(true)
.possible_values(&["true", "false"])
.case_insensitive(true)
.default_value("true")
.help("If --mode is 'glob': when set to 'true', files which do not have a known extension will skipped")
.arg(Arg::with_name(ARG_GLOB_NO_SKIP_UNSUPPORTED_EXTENSIONS)
.long("no-skip-unsupported-extensions")
.help("Files which don't have a known extension will not be skipped in glob mode")
.long_help("Only has an effect when --mode is 'glob'")
.takes_value(false)
)


// config(in):
.arg(Arg::with_name(ARG_SELECT_FRAME)
.long("select-frame")
Expand Down
16 changes: 8 additions & 8 deletions src/cli/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::cli::app::arg_names::{
ARG_GLOB_SKIP_UNSUPPORTED_EXTENSIONS, ARG_IMAGE_CRATE_FALLBACK, ARG_INPUT, ARG_MODE, ARG_OUTPUT,
ARG_GLOB_NO_SKIP_UNSUPPORTED_EXTENSIONS, ARG_IMAGE_CRATE_FALLBACK, ARG_INPUT, ARG_MODE,
ARG_OUTPUT,
};
use crate::cli::common_dir::CommonDir;
use crate::cli::glob_base_dir::glob_builder_base;
use anyhow::{bail, Context};
use boolean::Boolean;
use clap::{value_t, ArgMatches};
use clap::ArgMatches;
use globwalk::{FileType, GlobWalker};
use sic_image_engine::engine::Instr;
use sic_io::load::FrameIndex;
Expand Down Expand Up @@ -57,7 +57,7 @@ impl InputOutputMode {
(Some("glob"), Some(inputs), Some(output)) => InputOutputMode::Batch {
inputs: {
let inputs = Self::create_glob_walker(inputs)?;
let paths = Self::lookup_paths(inputs, value_t!(matches.value_of(ARG_GLOB_SKIP_UNSUPPORTED_EXTENSIONS), Boolean)?, matches.is_present(ARG_IMAGE_CRATE_FALLBACK))?;
let paths = Self::lookup_paths(inputs, !matches.is_present(ARG_GLOB_NO_SKIP_UNSUPPORTED_EXTENSIONS), matches.is_present(ARG_IMAGE_CRATE_FALLBACK))?;

CommonDir::try_new(paths)?
},
Expand All @@ -81,8 +81,8 @@ impl InputOutputMode {

fn lookup_paths(
inputs: impl Iterator<Item = Result<globwalk::DirEntry, globwalk::WalkError>>,
filter_unsupported: Boolean,
imagecrate_fallback_enabled: bool,
filter_unsupported: bool,
image_crate_fallback_enabled: bool,
) -> anyhow::Result<Vec<PathBuf>> {
let paths: Vec<PathBuf> = inputs
.map(|entry| {
Expand All @@ -97,8 +97,8 @@ impl InputOutputMode {
})
.collect::<anyhow::Result<Vec<PathBuf>>>()?;

Ok(if filter_unsupported.is_true() {
filter_unsupported_paths(paths, imagecrate_fallback_enabled)
Ok(if filter_unsupported {
filter_unsupported_paths(paths, image_crate_fallback_enabled)
} else {
paths
})
Expand Down

0 comments on commit 82afa32

Please sign in to comment.