Merge pull request #13844 from troymccabe/feature/13834-brew-docs-cmd

Adds `brew docs` to close #13834
This commit is contained in:
Mike McQuaid 2022-09-12 14:54:29 +01:00 committed by GitHub
commit c7bd51b995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# typed: true
# frozen_string_literal: true
require "cli/parser"
module Homebrew
extend T::Sig
module_function
sig { returns(CLI::Parser) }
def docs_args
Homebrew::CLI::Parser.new do
description <<~EOS
Open Homebrew's online documentation (#{HOMEBREW_DOCS_WWW}) in a browser.
EOS
end
end
sig { void }
def docs
exec_browser HOMEBREW_DOCS_WWW
end
end

View File

@ -45,6 +45,7 @@ HOMEBREW_REQUIRED_RUBY_VERSION = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").fre
HOMEBREW_PRODUCT = ENV.fetch("HOMEBREW_PRODUCT").freeze
HOMEBREW_VERSION = ENV.fetch("HOMEBREW_VERSION").freeze
HOMEBREW_WWW = "https://brew.sh"
HOMEBREW_DOCS_WWW = "https://docs.brew.sh"
HOMEBREW_SYSTEM = ENV.fetch("HOMEBREW_SYSTEM").freeze
HOMEBREW_PROCESSOR = ENV.fetch("HOMEBREW_PROCESSOR").freeze

View File

@ -0,0 +1,11 @@
# typed: false
# frozen_string_literal: true
describe "brew docs" do
it "opens the docs page", :integration_test do
expect { brew "docs", "HOMEBREW_BROWSER" => "echo" }
.to output("https://docs.brew.sh\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end