diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 803a4c0d..8487010f 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -49,45 +49,32 @@ impl App { } fn matches(interactive_output: bool) -> Result { - let args = if wild::args_os().nth(1) == Some("cache".into()) + let mut args = if wild::args_os().nth(1) == Some("cache".into()) || wild::args_os().any(|arg| arg == "--no-config") { // Skip the arguments in bats config file - let mut cli_args = wild::args_os(); - - // Load selected env vars - let mut args = get_args_from_env_vars(); - - // Put the zero-th CLI argument (program name) first - args.insert(0, cli_args.next().unwrap()); - - // .. and the rest at the end - cli_args.for_each(|a| args.push(a)); - - args + get_args_from_env_vars() } else { - let mut cli_args = wild::args_os(); - // Read arguments from bats config file let mut args = get_args_from_env_opts_var() .unwrap_or_else(get_args_from_config_file) .map_err(|_| "Could not parse configuration file")?; - // Put the zero-th CLI argument (program name) first - args.insert(0, cli_args.next().unwrap()); - - // env vars supersede config vars - get_args_from_env_vars() - .into_iter() - .for_each(|a| args.push(a)); - - // .. and the rest at the end - cli_args.for_each(|a| args.push(a)); + // Selected env vars supersede config vars + args.extend(get_args_from_env_vars()); args }; + let mut cli_args = wild::args_os(); + + // Put the zero-th CLI argument (program name) first + args.insert(0, cli_args.next().unwrap()); + + // .. and the rest at the end + cli_args.for_each(|a| args.push(a)); + Ok(clap_app::build_app(interactive_output).get_matches_from(args)) }