feat: bare string defaults to JQL extractor

This commit is contained in:
əlemi 2024-10-19 20:19:34 +02:00
parent cd99572fa2
commit 553a5fc68e
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -126,7 +126,6 @@ impl Endpoint {
.error_for_status()?;
Ok(match self.extract.unwrap_or_default() {
StringOr::Str(_query) => todo!(),
StringOr::T(Extractor::Discard) => "".to_string(),
StringOr::T(Extractor::Body) => format_body(res).await?,
StringOr::T(Extractor::Debug) => {
@ -142,11 +141,6 @@ impl Endpoint {
.to_str()?
.to_string()
+ "\n",
StringOr::T(Extractor::Jql { query }) => {
let json: serde_json::Value = res.json().await?;
let selection = jql_runner::runner::raw(&query, &json)?;
serde_json::to_string_pretty(&selection)?
},
StringOr::T(Extractor::Regex { pattern }) => {
let pattern = regex::Regex::new(&pattern)?;
let body = format_body(res).await?;
@ -155,6 +149,12 @@ impl Endpoint {
.as_str()
.to_string()
},
// bare string defaults to JQL query
StringOr::T(Extractor::Jql { query }) | StringOr::Str(query) => {
let json: serde_json::Value = res.json().await?;
let selection = jql_runner::runner::raw(&query, &json)?;
serde_json::to_string_pretty(&selection)?
},
})
}
}