mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::Missing
This commit is contained in:
parent
0cb608a80c
commit
a43224cb4a
@ -1,48 +1,46 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "formula"
|
||||
require "tab"
|
||||
require "diagnostic"
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
module Cmd
|
||||
class Missing < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Check the given <formula> kegs for missing dependencies. If no <formula> are
|
||||
provided, check all kegs. Will exit with a non-zero status if any kegs are found
|
||||
to be missing dependencies.
|
||||
EOS
|
||||
comma_array "--hide",
|
||||
description: "Act as if none of the specified <hidden> are installed. <hidden> should be " \
|
||||
"a comma-separated list of formulae."
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def missing_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Check the given <formula> kegs for missing dependencies. If no <formula> are
|
||||
provided, check all kegs. Will exit with a non-zero status if any kegs are found
|
||||
to be missing dependencies.
|
||||
EOS
|
||||
comma_array "--hide",
|
||||
description: "Act as if none of the specified <hidden> are installed. <hidden> should be " \
|
||||
"a comma-separated list of formulae."
|
||||
named_args :formula
|
||||
end
|
||||
|
||||
named_args :formula
|
||||
end
|
||||
end
|
||||
sig { override.void }
|
||||
def run
|
||||
return unless HOMEBREW_CELLAR.exist?
|
||||
|
||||
def missing
|
||||
args = missing_args.parse
|
||||
ff = if args.no_named?
|
||||
Formula.installed.sort
|
||||
else
|
||||
args.named.to_resolved_formulae.sort
|
||||
end
|
||||
|
||||
return unless HOMEBREW_CELLAR.exist?
|
||||
ff.each do |f|
|
||||
missing = f.missing_dependencies(hide: args.hide)
|
||||
next if missing.empty?
|
||||
|
||||
ff = if args.no_named?
|
||||
Formula.installed.sort
|
||||
else
|
||||
args.named.to_resolved_formulae.sort
|
||||
end
|
||||
|
||||
ff.each do |f|
|
||||
missing = f.missing_dependencies(hide: args.hide)
|
||||
next if missing.empty?
|
||||
|
||||
Homebrew.failed = true
|
||||
print "#{f}: " if ff.size > 1
|
||||
puts missing.join(" ")
|
||||
Homebrew.failed = true
|
||||
print "#{f}: " if ff.size > 1
|
||||
puts missing.join(" ")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/missing"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew missing" do
|
||||
RSpec.describe Homebrew::Cmd::Missing do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "prints missing dependencies", :integration_test do
|
||||
|
Loading…
x
Reference in New Issue
Block a user