From 67fd065e1d9a435d37f10b2f3b57fbe1305e6973 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Fri, 29 Mar 2024 18:19:17 -0700 Subject: [PATCH] Port Homebrew::Cmd::Docs --- Library/Homebrew/cmd/docs.rb | 25 ++++++++++++------------- Library/Homebrew/test/cmd/docs_spec.rb | 7 ++++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/cmd/docs.rb b/Library/Homebrew/cmd/docs.rb index 2ac9ef42af..9d5cedac92 100644 --- a/Library/Homebrew/cmd/docs.rb +++ b/Library/Homebrew/cmd/docs.rb @@ -1,22 +1,21 @@ # typed: strict # frozen_string_literal: true -require "cli/parser" +require "abstract_command" module Homebrew - module_function + module Cmd + class Docs < AbstractCommand + cmd_args do + description <<~EOS + Open Homebrew's online documentation at <#{HOMEBREW_DOCS_WWW}> in a browser. + EOS + end - sig { returns(CLI::Parser) } - def docs_args - Homebrew::CLI::Parser.new do - description <<~EOS - Open Homebrew's online documentation at <#{HOMEBREW_DOCS_WWW}> in a browser. - EOS + sig { override.void } + def run + exec_browser HOMEBREW_DOCS_WWW + end end end - - sig { void } - def docs - exec_browser HOMEBREW_DOCS_WWW - end end diff --git a/Library/Homebrew/test/cmd/docs_spec.rb b/Library/Homebrew/test/cmd/docs_spec.rb index 5379c21717..6262e54cf4 100644 --- a/Library/Homebrew/test/cmd/docs_spec.rb +++ b/Library/Homebrew/test/cmd/docs_spec.rb @@ -1,6 +1,11 @@ # frozen_string_literal: true -RSpec.describe "brew docs" do +require "cmd/docs" +require "cmd/shared_examples/args_parse" + +RSpec.describe Homebrew::Cmd::Docs do + it_behaves_like "parseable arguments" + it "opens the docs page", :integration_test do expect { brew "docs", "HOMEBREW_BROWSER" => "echo" } .to output("https://docs.brew.sh\n").to_stdout