1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-28 08:02:28 +01:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Keith Hall
6540f38827 cargo fmt 2025-09-27 23:54:52 +03:00
Keith Hall
f605db22e3 Fix help/version/diagnostic commands with invalid config 2025-09-27 23:33:10 +03:00
Keith Hall
2c87b9480f Bump jsonnet syntax dependency 2025-09-27 16:41:05 +03:00
Keith Hall
2ae4253577 Merge pull request #3397 from sharkdp/dependabot/submodules/assets/syntaxes/02_Extra/VimL-fe5bf5e
build(deps): bump assets/syntaxes/02_Extra/VimL from `ee85822` to `fe5bf5e`
2025-09-27 16:12:39 +03:00
dependabot[bot]
0d468b023a build(deps): bump assets/syntaxes/02_Extra/VimL
Bumps [assets/syntaxes/02_Extra/VimL](https://github.com/SalGnt/Sublime-VimL) from `ee85822` to `fe5bf5e`.
- [Release notes](https://github.com/SalGnt/Sublime-VimL/releases)
- [Commits](ee85822cbe...fe5bf5ea70)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/VimL
  dependency-version: fe5bf5ea7055b35035438c64d822aae1f1dfdb41
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-27 15:59:52 +03:00
6 changed files with 131 additions and 33 deletions

58
Cargo.lock generated
View File

@@ -157,7 +157,7 @@ dependencies = [
"syntect",
"tempfile",
"terminal-colorsaurus",
"thiserror 2.0.16",
"thiserror 2.0.11",
"toml",
"unicode-segmentation",
"unicode-width",
@@ -177,18 +177,24 @@ dependencies = [
[[package]]
name = "bit-set"
version = "0.8.0"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.8.0"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
@@ -374,7 +380,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"crossterm_winapi",
"libc",
"mio 0.8.11",
@@ -576,13 +582,12 @@ dependencies = [
[[package]]
name = "fancy-regex"
version = "0.16.2"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f"
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
dependencies = [
"bit-set",
"regex-automata",
"regex-syntax",
"regex",
]
[[package]]
@@ -672,7 +677,7 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"libc",
"libgit2-sys",
"log",
@@ -1057,7 +1062,7 @@ version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"cfg-if",
"cfg_aliases",
"libc",
@@ -1113,11 +1118,11 @@ dependencies = [
[[package]]
name = "onig"
version = "6.5.1"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
"bitflags",
"bitflags 1.3.2",
"libc",
"once_cell",
"onig_sys",
@@ -1289,7 +1294,7 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
dependencies = [
"bitflags",
"bitflags 2.6.0",
]
[[package]]
@@ -1336,7 +1341,7 @@ version = "0.38.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"errno",
"libc",
"linux-raw-sys",
@@ -1566,11 +1571,12 @@ dependencies = [
[[package]]
name = "syntect"
version = "5.3.0"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925"
checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1"
dependencies = [
"bincode",
"bitflags 1.3.2",
"fancy-regex",
"flate2",
"fnv",
@@ -1581,7 +1587,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"thiserror 2.0.16",
"thiserror 1.0.69",
"walkdir",
"yaml-rust",
]
@@ -1685,11 +1691,11 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.16"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
dependencies = [
"thiserror-impl 2.0.16",
"thiserror-impl 2.0.11",
]
[[package]]
@@ -1705,9 +1711,9 @@ dependencies = [
[[package]]
name = "thiserror-impl"
version = "2.0.16"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
dependencies = [
"proc-macro2",
"quote",
@@ -2263,7 +2269,7 @@ version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
dependencies = [
"bitflags",
"bitflags 2.6.0",
]
[[package]]

View File

@@ -11,7 +11,7 @@ exclude = ["assets/syntaxes/*", "assets/themes/*"]
build = "build/main.rs"
edition = '2021'
# You are free to bump MSRV as soon as a reason for bumping emerges.
rust-version = "1.79"
rust-version = "1.74"
[features]
default = ["application"]
@@ -82,7 +82,7 @@ optional = true
default-features = false
[dependencies.syntect]
version = "5.3.0"
version = "5.2.0"
default-features = false
features = ["parsing"]

View File

@@ -57,15 +57,30 @@ impl App {
}
fn matches(interactive_output: bool) -> Result<ArgMatches> {
// Check if we should skip config file processing for special arguments
// that don't require full application setup (help, version, diagnostic)
let should_skip_config = wild::args_os().any(|arg| {
matches!(
arg.to_str(),
Some("-h" | "--help" | "-V" | "--version" | "--diagnostic" | "--diagnostics")
)
});
let args = if wild::args_os().nth(1) == Some("cache".into()) {
// Skip the config file and env vars
wild::args_os().collect::<Vec<_>>()
} else if wild::args_os().any(|arg| arg == "--no-config") {
// Skip the arguments in bats config file
} else if wild::args_os().any(|arg| arg == "--no-config") || should_skip_config {
// Skip the arguments in bats config file when --no-config is present
// or when user requests help, version, or diagnostic information
let mut cli_args = wild::args_os();
let mut args = get_args_from_env_vars();
let mut args = if should_skip_config {
// For special commands, don't even try to load env vars that might fail
vec![]
} else {
get_args_from_env_vars()
};
// Put the zero-th CLI argument (program name) first
args.insert(0, cli_args.next().unwrap());

View File

@@ -1286,6 +1286,83 @@ fn diagnostic_sanity_check() {
.stderr("");
}
#[test]
fn help_works_with_invalid_config() {
let tmp_dir = tempdir().expect("can create temporary directory");
let tmp_config_path = tmp_dir.path().join("invalid-config.conf");
// Write an invalid config file
std::fs::write(&tmp_config_path, "--invalid-option").expect("can write config file");
// --help should work despite invalid config
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("--help")
.assert()
.success()
.stdout(predicate::str::contains(
"A cat(1) clone with syntax highlighting",
));
// -h should also work
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("-h")
.assert()
.success()
.stdout(predicate::str::contains("A cat(1) clone with wings"));
}
#[test]
fn version_works_with_invalid_config() {
let tmp_dir = tempdir().expect("can create temporary directory");
let tmp_config_path = tmp_dir.path().join("invalid-config.conf");
// Write an invalid config file
std::fs::write(&tmp_config_path, "--invalid-option").expect("can write config file");
// --version should work despite invalid config
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("--version")
.assert()
.success()
.stdout(predicate::str::contains("bat "));
// -V should also work
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("-V")
.assert()
.success()
.stdout(predicate::str::contains("bat "));
}
#[test]
fn diagnostic_works_with_invalid_config() {
let tmp_dir = tempdir().expect("can create temporary directory");
let tmp_config_path = tmp_dir.path().join("invalid-config.conf");
// Write an invalid config file
std::fs::write(&tmp_config_path, "--invalid-option").expect("can write config file");
// --diagnostic should work despite invalid config
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("--diagnostic")
.assert()
.success()
.stdout(predicate::str::contains("#### Software version"));
// --diagnostics (alias) should also work
bat_with_config()
.env("BAT_CONFIG_PATH", tmp_config_path.to_str().unwrap())
.arg("--diagnostics")
.assert()
.success()
.stdout(predicate::str::contains("#### Software version"));
}
#[test]
fn config_location_test() {
bat_with_config()