Port Homebrew::Cmd::Home
This commit is contained in:
parent
d0c1af4f9e
commit
74218c0483
@ -1,15 +1,13 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class Home < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def home_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Open a <formula> or <cask>'s homepage in a browser, or open
|
Open a <formula> or <cask>'s homepage in a browser, or open
|
||||||
Homebrew's own homepage if no argument is provided.
|
Homebrew's own homepage if no argument is provided.
|
||||||
@ -23,12 +21,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask]
|
named_args [:formula, :cask]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def home
|
|
||||||
args = home_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
if args.no_named?
|
if args.no_named?
|
||||||
exec_browser HOMEBREW_WWW
|
exec_browser HOMEBREW_WWW
|
||||||
return
|
return
|
||||||
@ -51,4 +46,6 @@ module Homebrew
|
|||||||
"Cask #{formula_or_cask.token}"
|
"Cask #{formula_or_cask.token}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/help"
|
require "cmd/help"
|
||||||
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe Homebrew::Cmd::HelpCmd, :integration_test do
|
RSpec.describe Homebrew::Cmd::HelpCmd, :integration_test do
|
||||||
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
describe "help" do
|
describe "help" do
|
||||||
it "prints help for a documented Ruby command" do
|
it "prints help for a documented Ruby command" do
|
||||||
expect { brew "help", "cat" }
|
expect { brew "help", "cat" }
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/home"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew home" do
|
RSpec.describe Homebrew::Cmd::Home do
|
||||||
let(:testballhome_homepage) do
|
let(:testballhome_homepage) do
|
||||||
Formula["testballhome"].homepage
|
Formula["testballhome"].homepage
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user