commands: fix some syntax errors reporting literals
Some checks failed
Build and test / build (push) Successful in 59s
Build and test / check (push) Failing after 58s
Build and test / docs (push) Successful in 1m21s
Build and test / test (push) Successful in 1m37s

This commit is contained in:
Oystein Kristoffer Tveit 2024-12-14 00:19:25 +01:00
parent 9cef59eb88
commit 366f56da9e
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
10 changed files with 21 additions and 22 deletions

View File

@ -23,12 +23,12 @@ impl Command for Count {
let filter = parse_filter(&mut parts)?; let filter = parse_filter(&mut parts)?;
let group = if let Some("group") = parts.next() { let group = if let Some("group") = parts.next() {
let group = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
Some( Some(
parts group
.next()
.ok_or(RequestParserError::UnexpectedEOF)?
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?, .map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
) )
} else { } else {
None None

View File

@ -19,7 +19,7 @@ impl Command for GetFingerprint {
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let uri = uri let uri = uri
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?; .map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
debug_assert!(parts.next().is_none()); debug_assert!(parts.next().is_none());

View File

@ -18,7 +18,7 @@ impl Command for List {
let tagtype = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let tagtype = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let tagtype = tagtype let tagtype = tagtype
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "tagtype".to_owned()))?; .map_err(|_| RequestParserError::SyntaxError(1, tagtype.to_owned()))?;
// TODO: This should be optional // TODO: This should be optional
let filter = parse_filter(&mut parts)?; let filter = parse_filter(&mut parts)?;
@ -28,7 +28,7 @@ impl Command for List {
Some( Some(
group group
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?, .map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
) )
} else { } else {
None None
@ -50,11 +50,11 @@ impl Command for List {
let list = parts let list = parts
.0 .0
.iter() .iter()
.map(|(_, v)| match v { .map(|(k, v)| match v {
GenericResponseValue::Text(value) => Ok(value.to_string()), GenericResponseValue::Text(value) => Ok(value.to_string()),
GenericResponseValue::Binary(_) => Err( GenericResponseValue::Binary(_) => {
ResponseParserError::UnexpectedPropertyType("handler", "Binary"), Err(ResponseParserError::UnexpectedPropertyType(k, "Binary"))
), }
}) })
.collect::<Result<Vec<_>, ResponseParserError>>()?; .collect::<Result<Vec<_>, ResponseParserError>>()?;

View File

@ -17,7 +17,7 @@ impl Command for ListAll {
.next() .next()
.map(|s| { .map(|s| {
s.parse() s.parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned())) .map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
}) })
.transpose()?; .transpose()?;

View File

@ -18,7 +18,7 @@ impl Command for ListAllInfo {
.next() .next()
.map(|s| { .map(|s| {
s.parse() s.parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned())) .map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
}) })
.transpose()?; .transpose()?;

View File

@ -17,7 +17,7 @@ impl Command for ListFiles {
.next() .next()
.map(|s| { .map(|s| {
s.parse() s.parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned())) .map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
}) })
.transpose()?; .transpose()?;

View File

@ -17,7 +17,7 @@ impl Command for LsInfo {
.next() .next()
.map(|s| { .map(|s| {
s.parse() s.parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned())) .map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
}) })
.transpose()?; .transpose()?;

View File

@ -17,7 +17,7 @@ impl Command for ReadComments {
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let uri = uri let uri = uri
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?; .map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
debug_assert!(parts.next().is_none()); debug_assert!(parts.next().is_none());

View File

@ -23,12 +23,11 @@ impl Command for SearchCount {
let filter = parse_filter(&mut parts)?; let filter = parse_filter(&mut parts)?;
let group = if let Some("group") = parts.next() { let group = if let Some("group") = parts.next() {
let group = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
Some( Some(
parts group
.next()
.ok_or(RequestParserError::UnexpectedEOF)?
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?, .map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
) )
} else { } else {
None None

View File

@ -17,12 +17,12 @@ impl Command for StickerList {
let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let sticker_type = sticker_type let sticker_type = sticker_type
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "sticker_type".to_owned()))?; .map_err(|_| RequestParserError::SyntaxError(1, sticker_type.to_owned()))?;
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let uri = uri let uri = uri
.parse() .parse()
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?; .map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
debug_assert!(parts.next().is_none()); debug_assert!(parts.next().is_none());