Port Homebrew::DevCmd::Unpack

This commit is contained in:
Douglas Eichelberger 2024-03-21 22:04:10 -07:00
parent ba5f392d4c
commit bdf8fbc1ad
2 changed files with 61 additions and 56 deletions

View File

@ -1,14 +1,18 @@
# typed: true
# typed: strict
# frozen_string_literal: true
require "abstract_command"
require "fileutils"
require "stringio"
require "formula"
require "cli/parser"
module Homebrew
sig { returns(CLI::Parser) }
def self.unpack_args
Homebrew::CLI::Parser.new do
module DevCmd
class Unpack < AbstractCommand
include FileUtils
cmd_args do
description <<~EOS
Unpack the source files for <formula> into subdirectories of the current
working directory.
@ -27,11 +31,9 @@ module Homebrew
named_args :formula, min: 1
end
end
def self.unpack
args = unpack_args.parse
sig { override.void }
def run
formulae = args.named.to_formulae
if (dir = args.destdir)
@ -73,3 +75,5 @@ module Homebrew
end
end
end
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "dev-cmd/unpack"
RSpec.describe "brew unpack" do
RSpec.describe Homebrew::DevCmd::Unpack do
it_behaves_like "parseable arguments"
it "unpacks a given Formula's archive", :integration_test do