Port Homebrew::DevCmd::Command
This commit is contained in:
parent
55a0991902
commit
777ee12258
@ -1,30 +1,29 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "commands"
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
module DevCmd
|
||||
class Command < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Display the path to the file being used when invoking `brew` <cmd>.
|
||||
EOS
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def command_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Display the path to the file being used when invoking `brew` <cmd>.
|
||||
EOS
|
||||
named_args :command, min: 1
|
||||
end
|
||||
|
||||
named_args :command, min: 1
|
||||
end
|
||||
end
|
||||
|
||||
def command
|
||||
args = command_args.parse
|
||||
|
||||
args.named.each do |cmd|
|
||||
path = Commands.path(cmd)
|
||||
odie "Unknown command: #{cmd}" unless path
|
||||
puts path
|
||||
sig { override.void }
|
||||
def run
|
||||
args.named.each do |cmd|
|
||||
path = Commands.path(cmd)
|
||||
odie "Unknown command: #{cmd}" unless path
|
||||
puts path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "dev-cmd/command"
|
||||
|
||||
RSpec.describe "brew command" do
|
||||
it_behaves_like "parseable arguments"
|
||||
RSpec.describe Homebrew::DevCmd::Command do
|
||||
it_behaves_like "parseable arguments", argv: ["foo"]
|
||||
|
||||
it "returns the file for a given command", :integration_test do
|
||||
expect { brew "command", "info" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user