mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 09:13:39 +01:00
Add possibility for spaces on a single line
This commit is contained in:
parent
8275b0436d
commit
693bd5929d
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -68,6 +68,7 @@ dependencies = [
|
|||||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"syntect 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wild 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wild 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -677,6 +678,11 @@ dependencies = [
|
|||||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shell-words"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
@ -1010,6 +1016,7 @@ dependencies = [
|
|||||||
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
|
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
|
||||||
"checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
|
"checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
|
||||||
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
|
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
|
||||||
|
"checksum shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39acde55a154c4cd3ae048ac78cc21c25f3a0145e44111b523279113dce0d94a"
|
||||||
"checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d"
|
"checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d"
|
||||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||||
|
@ -24,6 +24,7 @@ lazy_static = "1.0"
|
|||||||
wild = "2.0"
|
wild = "2.0"
|
||||||
content_inspector = "0.2.3"
|
content_inspector = "0.2.3"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
|
shell-words = "0.1.0"
|
||||||
|
|
||||||
[dependencies.git2]
|
[dependencies.git2]
|
||||||
version = "0.7"
|
version = "0.7"
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use shell_words;
|
||||||
|
|
||||||
use dirs::PROJECT_DIRS;
|
use dirs::PROJECT_DIRS;
|
||||||
|
|
||||||
pub fn get_args_from_config_file() -> Vec<OsString> {
|
pub fn get_args_from_config_file() -> Vec<OsString> {
|
||||||
@ -16,6 +18,7 @@ fn get_args_from_str<'a>(content: &'a str) -> Vec<OsString> {
|
|||||||
.map(|line| line.trim())
|
.map(|line| line.trim())
|
||||||
.filter(|line| !line.is_empty())
|
.filter(|line| !line.is_empty())
|
||||||
.filter(|line| !line.starts_with("#"))
|
.filter(|line| !line.starts_with("#"))
|
||||||
|
.flat_map(|line| shell_words::split(line).unwrap())
|
||||||
.map(|line| line.into())
|
.map(|line| line.into())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
@ -23,7 +26,6 @@ fn get_args_from_str<'a>(content: &'a str) -> Vec<OsString> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn empty() {
|
fn empty() {
|
||||||
let args = get_args_from_str("");
|
let args = get_args_from_str("");
|
||||||
println!("{:?}", args);
|
|
||||||
assert!(args.is_empty());
|
assert!(args.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ fn multiple() {
|
|||||||
--color=always
|
--color=always
|
||||||
";
|
";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec!["-p", "--style numbers,changes", "--color=always"],
|
vec!["-p", "--style", "numbers,changes", "--color=always"],
|
||||||
get_args_from_str(config)
|
get_args_from_str(config)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -59,7 +61,7 @@ fn comments() {
|
|||||||
--color=always
|
--color=always
|
||||||
";
|
";
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec!["-p", "--style numbers,changes", "--color=always"],
|
vec!["-p", "--style", "numbers,changes", "--color=always"],
|
||||||
get_args_from_str(config)
|
get_args_from_str(config)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user