aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crates/yt/Cargo.toml2
-rw-r--r--crates/yt/src/select/selection_file/mod.rs24
2 files changed, 18 insertions, 8 deletions
diff --git a/crates/yt/Cargo.toml b/crates/yt/Cargo.toml
index 7289a4c..c6d8c30 100644
--- a/crates/yt/Cargo.toml
+++ b/crates/yt/Cargo.toml
@@ -37,8 +37,8 @@ sqlx = { version = "0.8.6", features = ["runtime-tokio", "sqlite"] }
stderrlog = "0.6.0"
tempfile = "3.20.0"
toml = "0.8.23"
-trinitry = { version = "0.2.2" }
xdg = "3.0.0"
+shlex = "1.3.0"
bytes.workspace = true
libmpv2.workspace = true
log.workspace = true
diff --git a/crates/yt/src/select/selection_file/mod.rs b/crates/yt/src/select/selection_file/mod.rs
index abd26c4..f5e0531 100644
--- a/crates/yt/src/select/selection_file/mod.rs
+++ b/crates/yt/src/select/selection_file/mod.rs
@@ -11,22 +11,32 @@
//! The data structures needed to express the file, which the user edits
-use anyhow::{Context, Result};
-use trinitry::Trinitry;
+use anyhow::{Result, bail};
+use shlex::Shlex;
pub mod duration;
+/// # Panics
+/// If internal assertions fail.
pub fn process_line(line: &str) -> Result<Option<Vec<String>>> {
// Filter out comments and empty lines
if line.starts_with('#') || line.trim().is_empty() {
Ok(None)
} else {
- let tri = Trinitry::new(line).with_context(|| format!("Failed to parse line '{line}'"))?;
+ let split: Vec<_> = {
+ let mut shl = Shlex::new(line);
+ let res = shl.by_ref().collect();
- let mut vec = Vec::with_capacity(tri.arguments().len() + 1);
- vec.push(tri.command().to_owned());
- vec.extend(tri.arguments().to_vec());
+ if shl.had_error {
+ bail!("Failed to parse line '{line}'")
+ }
- Ok(Some(vec))
+ assert_eq!(shl.line_no, 1, "A unexpected newline appeared");
+ res
+ };
+
+ assert!(!split.is_empty());
+
+ Ok(Some(split))
}
}