brew/Library/Homebrew/cmd/readall.rb

69 lines
2.4 KiB
Ruby
Raw Normal View History

2024-04-01 10:05:02 -07:00
# typed: strict
# frozen_string_literal: true
2024-04-01 10:05:02 -07:00
require "abstract_command"
require "readall"
require "env_config"
module Homebrew
2024-04-01 10:05:02 -07:00
module Cmd
class ReadallCmd < AbstractCommand
cmd_args do
description <<~EOS
Import all items from the specified <tap>, or from all installed taps if none is provided.
This can be useful for debugging issues across all items when making
significant changes to `formula.rb`, testing the performance of loading
all items or checking if any current formulae/casks have Ruby issues.
EOS
flag "--os=",
description: "Read using the given operating system. (Pass `all` to simulate all operating systems.)"
flag "--arch=",
description: "Read using the given CPU architecture. (Pass `all` to simulate all architectures.)"
switch "--aliases",
description: "Verify any alias symlinks in each tap."
switch "--syntax",
description: "Syntax-check all of Homebrew's Ruby files (if no <tap> is passed)."
switch "--eval-all",
description: "Evaluate all available formulae and casks, whether installed or not. " \
"Implied if `$HOMEBREW_EVAL_ALL` is set."
2024-04-01 10:05:02 -07:00
switch "--no-simulate",
description: "Don't simulate other system configurations when checking formulae and casks."
2016-09-26 01:44:51 +02:00
2024-04-01 10:05:02 -07:00
named_args :tap
end
2021-01-10 14:26:40 -05:00
2024-04-01 10:05:02 -07:00
sig { override.void }
def run
Homebrew.with_no_api_env do
if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/})
2018-11-05 18:23:26 +05:30
2024-04-01 10:05:02 -07:00
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
end
2018-11-05 18:23:26 +05:30
2024-04-01 10:05:02 -07:00
options = {
aliases: args.aliases?,
no_simulate: args.no_simulate?,
}
options[:os_arch_combinations] = args.os_arch_combinations if args.os || args.arch
2024-04-01 10:05:02 -07:00
taps = if args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
raise UsageError, "`brew readall` needs a tap or `--eval-all` passed or `$HOMEBREW_EVAL_ALL` set!"
2024-04-01 10:05:02 -07:00
end
2024-04-01 10:05:02 -07:00
Tap.installed
else
args.named.to_installed_taps
end
2024-04-01 10:05:02 -07:00
taps.each do |tap|
Homebrew.failed = true unless Readall.valid_tap?(tap, **options)
end
2024-02-20 19:36:57 +01:00
end
end
end
2010-07-18 14:20:54 -07:00
end
end