readall: Use CLI::Parser to parse args
This commit is contained in:
parent
f9bfa63167
commit
bf51e3ea14
@ -10,19 +10,41 @@
|
|||||||
#: If `--syntax` is passed, also syntax-check all of Homebrew's Ruby files.
|
#: If `--syntax` is passed, also syntax-check all of Homebrew's Ruby files.
|
||||||
|
|
||||||
require "readall"
|
require "readall"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def readall_args
|
||||||
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`readall` [<options>] [<taps>]
|
||||||
|
|
||||||
|
Import all formulae from specified <taps> (defaults to all installed taps).
|
||||||
|
This can be useful for debugging issues across all formulae when making
|
||||||
|
significant changes to `formula.rb`, testing the performance of loading
|
||||||
|
all formulae or to determine if any current formulae have Ruby issues.
|
||||||
|
EOS
|
||||||
|
switch "--aliases",
|
||||||
|
description: "Verify any alias symlinks in each tap."
|
||||||
|
switch "--syntax",
|
||||||
|
description: "Syntax-check all of Homebrew's Ruby files."
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def readall
|
def readall
|
||||||
if ARGV.include?("--syntax")
|
readall_args.parse
|
||||||
|
|
||||||
|
if args.syntax?
|
||||||
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
|
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
|
||||||
ruby_files = Dir.glob(scan_files).reject { |file| file =~ %r{/(vendor|cask)/} }
|
ruby_files = Dir.glob(scan_files).reject { |file| file =~ %r{/(vendor|cask)/} }
|
||||||
|
|
||||||
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
|
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
|
||||||
end
|
end
|
||||||
|
|
||||||
options = { aliases: ARGV.include?("--aliases") }
|
options = { aliases: args.aliases? }
|
||||||
taps = if ARGV.named.empty?
|
taps = if ARGV.named.empty?
|
||||||
Tap
|
Tap
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user