Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
refactor(cli): encapsulate response body regex
ldm0e7a8a709ef05
diff --git a/moli/src/cli.rs b/moli/src/cli.rsindex 92a852aa7..83163bf9a 100644--- a/moli/src/cli.rs+++ b/moli/src/cli.rs@@ -96,7 +96,11 @@ pub struct FetchArgs {/// Wait for a response whose body matches this regex. An invalid regex/// fails the fetch command immediately.- #[arg(long, value_parser = parse_response_body_regex)]+ #[arg(+ long,+ value_name = "REGEX",+ value_parser = parse_response_body_regex+ )]pub wait_response_body: Option<ResponseBodyRegexArg>,#[arg(long, value_parser = parse_response_json_path_arg)]@@ -171,10 +175,14 @@ fn parse_response_json_path_arg(raw: &str) -> Result<ResponseJsonPathArg, String#[derive(Debug, Clone)]pub struct ResponseBodyRegexArg {- pub regex: Regex,+ regex: Regex,}impl ResponseBodyRegexArg {+ pub(crate) fn regex(&self) -> &Regex {+ &self.regex+ }+pub fn pattern(&self) -> &str {self.regex.as_str()}@@ -592,6 +600,15 @@ mod tests {assert!(help.contains("response match, selector, and script waits share one absolute"));}+ #[test]+ fn fetch_help_labels_response_body_pattern_as_regex() {+ let help = Cli::try_parse_from(["moli", "fetch", "--help"])+ .unwrap_err()+ .to_string();++ assert!(help.contains("--wait-response-body <REGEX>"));+ }+#[test]fn parses_port_equals_with_explicit_serve_command() {let args = normalize_args_for_compat(["moli", "serve", "--port=0"]);diff --git a/moli/src/config.rs b/moli/src/config.rsindex 2311a33b0..e95dd7628 100644--- a/moli/src/config.rs+++ b/moli/src/config.rs@@ -302,7 +302,7 @@ pub fn response_wait_criteria_from_args(body_regex: args.wait_response_body.as_ref()- .map(|arg| arg.regex.clone()),+ .map(|arg| arg.regex().clone()),json_path_equals: args.wait_response_json.as_ref()