Skip to content

Commit

Permalink
Merge pull request #13844 from troymccabe/feature/13834-brew-docs-cmd
Browse files Browse the repository at this point in the history
Adds `brew docs` to close #13834
  • Loading branch information
MikeMcQuaid committed Sep 12, 2022
2 parents 6e2b162 + dbb9af4 commit c7bd51b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Library/Homebrew/cmd/docs.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
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

Expand Down
11 changes: 11 additions & 0 deletions Library/Homebrew/test/cmd/docs_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c7bd51b

Please sign in to comment.