diff --git a/moli/src/app.rs b/moli/src/app.rs index e9f2aa8f74..5c54604a4a 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( 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( ); server.serve().await.context("protocol server failed")?; } - Commands::Help | Commands::Version => unreachable!(), } Ok(()) diff --git a/moli/src/cli.rs b/moli/src/cli.rs index c274840583..3380ec0971 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), Serve(Box), - Help, - Version, } #[derive(Debug, Clone, PartialEq, Eq, Args)] diff --git a/moli/src/config.rs b/moli/src/config.rs index 28e9794386..b6a8aef87e 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.rs index f8833a6d55..1097471793 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.ps1 index 9e45c56814..7a5e21eed2 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.sh index eb1d577c15..77acaa2c46 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" ;; esac diff --git a/skills/moli-cdp-server/SKILL.md b/skills/moli-cdp-server/SKILL.md index aba4765c93..ab11493eb4 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 default location 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 endpoint diff --git a/skills/moli-webfetch/SKILL.md b/skills/moli-webfetch/SKILL.md index 51fc436121..5546279470 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 default location 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: