Support backticks in skysh

next
Sayan Nandan 3 years ago
parent 9b132f4351
commit f33b8dc00c
No known key found for this signature in database
GPG Key ID: 2932644755A97720

@ -34,6 +34,7 @@ use skytable::{types::RawString, Query};
#[derive(Debug, PartialEq)]
pub enum TokenizerError {
QuoteMismatch(String),
BacktickMismatch(String),
ExpectedWhitespace(String),
}
@ -44,6 +45,9 @@ impl fmt::Display for TokenizerError {
Self::ExpectedWhitespace(expr) => {
write!(f, "expected whitespace near end of: `{}`", expr)
}
Self::BacktickMismatch(expr) => {
write!(f, "mismatched backticks near end of: `{}`", expr)
}
}
}
}
@ -128,6 +132,21 @@ pub fn get_query<T: SequentialQuery>(inp: &[u8]) -> Result<T, TokenizerError> {
}
expect_whitespace!(pos);
}
b'`' => {
// hmm, backtick? let's look for the end
let pos = pos!();
let qidx = it.position(|x| *x == b'`');
match qidx {
Some(idx) => query.push(&inp[pos..idx + pos]),
None => {
let end = pos!();
return Err(TokenizerError::BacktickMismatch(
String::from_utf8_lossy(&inp[pos..end]).to_string(),
));
}
}
expect_whitespace!(pos);
}
b' ' => {
// this just prevents control from being handed to the wildcard
continue;

@ -54,6 +54,6 @@ macro_rules! set_if_exists {
macro_rules! ret_cli_err {
($what:expr) => {
return Err(self::cfgerr::ConfigError::CliArgErr($what));
return Err(self::cfgerr::ConfigError::CliArgErr($what))
};
}

Loading…
Cancel
Save