Port Homebrew::Cmd::Docs

This commit is contained in:
Douglas Eichelberger 2024-03-29 18:19:17 -07:00
parent bde44cfc99
commit 67fd065e1d
2 changed files with 18 additions and 14 deletions

View File

@ -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

View File

@ -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