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): remove help and version subcommands
ldm0be85a67d54c3
diff --git a/moli/src/app.rs b/moli/src/app.rsindex e9f2aa8f7..5c54604a4 100644--- a/moli/src/app.rs+++ b/moli/src/app.rs@@ -11,7 +11,7 @@ use crate::{};use anyhow::Result;use anyhow::{Context, anyhow};-use clap::{CommandFactory, Parser};+use clap::Parser;use moli_core::runtime::{Browser, FetchedDocument, NavigationRuntimeConfig, PageVmInitStage, RenderedDomWaitUntil,storage_partition::StoragePartitionState,@@ -39,23 +39,6 @@ pub async fn run_cli_with_config<W: Write>(config: AppConfig,stdout: &mut W,) -> Result<()> {- match cli.command.clone() {- Commands::Help => {- let mut command = Cli::command();- command- .write_long_help(&mut *stdout)- .context("failed to print CLI help")?;- writeln!(stdout).context("failed to write CLI help trailing newline")?;- return Ok(());- }- Commands::Version => {- writeln!(stdout, "{}", env!("CARGO_PKG_VERSION"))- .context("failed to write CLI version")?;- return Ok(());- }- _ => {}- }-match cli.command {Commands::Fetch(args) => {let browser = Browser::new(config.browser.clone())@@ -253,7 +236,6 @@ pub async fn run_cli_with_config<W: Write>();server.serve().await.context("protocol server failed")?;}- Commands::Help | Commands::Version => unreachable!(),}Ok(())diff --git a/moli/src/cli.rs b/moli/src/cli.rsindex c27484058..3380ec097 100644--- a/moli/src/cli.rs+++ b/moli/src/cli.rs@@ -39,7 +39,7 @@ const FETCH_INFER_FLAGS: &[&str] = &["--web-bot-auth-profile",];const SERVE_INFER_FLAGS: &[&str] = &["--host", "--port", "--timeout", "--layout"];-const EXPLICIT_COMMANDS: &[&str] = &["fetch", "serve", "help", "version"];+const EXPLICIT_COMMANDS: &[&str] = &["fetch", "serve"];const DUMP_MODES: &[&str] = &["json","html",@@ -69,8 +69,6 @@ pub struct Cli {pub enum Commands {Fetch(Box<FetchArgs>),Serve(Box<ServeArgs>),- Help,- Version,}#[derive(Debug, Clone, PartialEq, Eq, Args)]diff --git a/moli/src/config.rs b/moli/src/config.rsindex 28e979438..b6a8aef87 100644--- a/moli/src/config.rs+++ b/moli/src/config.rs@@ -58,7 +58,6 @@ impl AppConfig {config.server.cdp_max_connections = args.cdp_max_connections;config.server.cdp_max_pending_connections = args.cdp_max_pending_connections;}- Commands::Help | Commands::Version => {}}Ok(config)diff --git a/moli/tests/cli.rs b/moli/tests/cli.rsindex f8833a6d5..109747179 100644--- a/moli/tests/cli.rs+++ b/moli/tests/cli.rs@@ -580,15 +580,22 @@ fn infers_serve_mode_from_legacy_serve_flags() {}#[test]-fn parses_version_and_help_commands() {- assert_eq!(- Cli::try_parse_from(["moli", "version"]).unwrap().command,- Commands::Version- );- assert_eq!(- Cli::try_parse_from(["moli", "help"]).unwrap().command,- Commands::Help- );+fn rejects_removed_version_and_help_subcommands() {+ for command in ["version", "help"] {+ let error = Cli::try_parse_from(["moli", command]).unwrap_err();+ assert_eq!(error.kind(), clap::error::ErrorKind::InvalidSubcommand);+ }+}++#[test]+fn standard_version_and_help_flags_remain_available() {+ for (flag, expected_kind) in [+ ("--version", clap::error::ErrorKind::DisplayVersion),+ ("--help", clap::error::ErrorKind::DisplayHelp),+ ] {+ let error = Cli::try_parse_from(["moli", flag]).unwrap_err();+ assert_eq!(error.kind(), expected_kind);+ }}#[test]diff --git a/scripts/install.ps1 b/scripts/install.ps1index 9e45c5681..7a5e21eed 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -39,7 +39,7 @@ try {$pathEntries = $env:PATH -split ";"if ($installDir -notin $pathEntries) {- Write-Host "Add $installDir to PATH, then run: moli version"+ Write-Host "Add $installDir to PATH, then run: moli --version"}} finally {if (Test-Path -LiteralPath $tempDir) {diff --git a/scripts/install.sh b/scripts/install.shindex eb1d577c1..77acaa2c4 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -78,6 +78,6 @@ printf 'Installed moli to %s/moli\n' "$moli_install_dir"case ":${PATH:-}:" in*":$moli_install_dir:"*) ;;*)- printf 'Add %s to PATH, then run: moli version\n' "$moli_install_dir"+ printf 'Add %s to PATH, then run: moli --version\n' "$moli_install_dir";;esacdiff --git a/skills/moli-cdp-server/SKILL.md b/skills/moli-cdp-server/SKILL.mdindex aba4765c9..ab11493eb 100644--- a/skills/moli-cdp-server/SKILL.md+++ b/skills/moli-cdp-server/SKILL.md@@ -26,7 +26,7 @@ Preserve the client's existing API where Moli supports it.irm https://github.com/lexmount/moli/releases/latest/download/moli-installer.ps1 | iex```- Resolve the installed binary again and run `moli version`. The default+ Resolve the installed binary again and run `moli --version`. The defaultlocation is `~/.local/bin/moli` on Linux/macOS and`%LOCALAPPDATA%\Moli\bin\moli.exe` on Windows when it is not yet on `PATH`.2. Start `moli serve` on the default loopback endpointdiff --git a/skills/moli-webfetch/SKILL.md b/skills/moli-webfetch/SKILL.mdindex 51fc43612..554627947 100644--- a/skills/moli-webfetch/SKILL.md+++ b/skills/moli-webfetch/SKILL.md@@ -27,7 +27,7 @@ structure-first; enable layout only when the result needs pixels or pagination.irm https://github.com/lexmount/moli/releases/latest/download/moli-installer.ps1 | iex```- Resolve the installed binary again and run `moli version`. The default+ Resolve the installed binary again and run `moli --version`. The defaultlocation is `~/.local/bin/moli` on Linux/macOS and`%LOCALAPPDATA%\Moli\bin\moli.exe` on Windows when it is not yet on `PATH`.2. Fetch the seed URL as Markdown with the default completion strategy: