Port Homebrew::DevCmd::Cat
This commit is contained in:
parent
df42e9cfb3
commit
55a0991902
@ -1,12 +1,15 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
sig { returns(CLI::Parser) }
|
module DevCmd
|
||||||
def self.cat_args
|
class Cat < AbstractCommand
|
||||||
Homebrew::CLI::Parser.new do
|
include FileUtils
|
||||||
|
|
||||||
|
cmd_args do
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Display the source of a <formula> or <cask>.
|
Display the source of a <formula> or <cask>.
|
||||||
EOS
|
EOS
|
||||||
@ -20,11 +23,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask], min: 1, without_api: true
|
named_args [:formula, :cask], min: 1, without_api: true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.cat
|
|
||||||
args = cat_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
cd HOMEBREW_REPOSITORY do
|
cd HOMEBREW_REPOSITORY do
|
||||||
pager = if Homebrew::EnvConfig.bat?
|
pager = if Homebrew::EnvConfig.bat?
|
||||||
ENV["BAT_CONFIG_PATH"] = Homebrew::EnvConfig.bat_config_path
|
ENV["BAT_CONFIG_PATH"] = Homebrew::EnvConfig.bat_config_path
|
||||||
@ -60,3 +61,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
require "dev-cmd/cat"
|
||||||
|
|
||||||
RSpec.describe "brew cat" do
|
RSpec.describe Homebrew::DevCmd::Cat do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments", argv: ["foo"]
|
||||||
|
|
||||||
it "prints the content of a given Formula", :integration_test do
|
it "prints the content of a given Formula", :integration_test do
|
||||||
formula_file = setup_test_formula "testball"
|
formula_file = setup_test_formula "testball"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user