Port Homebrew::DevCmd::Command

This commit is contained in:
Douglas Eichelberger 2024-03-19 11:50:53 -07:00
parent 55a0991902
commit 777ee12258
2 changed files with 21 additions and 21 deletions

View File

@ -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

View File

@ -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" }