From 72152296c79dc1e758bcd8c3111c0c3e475c4bbe Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 10 May 2019 14:02:08 -0500 Subject: [PATCH] Fix accidental printing of files named 'cache' This also adds two regression tests, so this will hopefully not pop up again. closes #557 --- Cargo.lock | 2 ++ src/clap_app.rs | 1 - tests/examples/cache | 1 + tests/integration_tests.rs | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/examples/cache diff --git a/Cargo.lock b/Cargo.lock index 2790b471..267e0755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "adler32" version = "1.0.3" diff --git a/src/clap_app.rs b/src/clap_app.rs index adce2b1d..16c36d25 100644 --- a/src/clap_app.rs +++ b/src/clap_app.rs @@ -18,7 +18,6 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { .global_setting(AppSettings::DeriveDisplayOrder) .global_setting(AppSettings::UnifiedHelpMessage) .global_setting(AppSettings::HidePossibleValuesInHelp) - .setting(AppSettings::InferSubcommands) .setting(AppSettings::ArgsNegateSubcommands) .setting(AppSettings::DisableHelpSubcommand) .setting(AppSettings::VersionlessSubcommands) diff --git a/tests/examples/cache b/tests/examples/cache new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/examples/cache @@ -0,0 +1 @@ +test diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 7d9856ac..ec1ffd3f 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -448,3 +448,18 @@ fn utf16() { .success() .stdout(std::str::from_utf8(b"\xEF\xBB\xBFhello world\n").unwrap()); } + +#[test] +fn can_print_file_named_cache() { + bat() + .arg("cache") + .assert() + .success() + .stdout("test\n") + .stderr(""); +} + +#[test] +fn does_not_print_unwanted_file_named_cache() { + bat_with_config().arg("cach").assert().failure(); +}