Mike McQuaid 70b93f65ea
*cmd/*: use *system instead of exec for easier testing.
This improves both test coverage, makes it easier to use a profiler and
a debugger.
2019-03-27 21:15:24 +00:00

30 lines
661 B
Ruby

require "cli_parser"
module Homebrew
module_function
def ruby_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`ruby` [`-e`]:
Run a Ruby instance with Homebrew's libraries loaded e.g.
`brew ruby -e "puts :gcc.f.deps"` or `brew ruby script.rb`
EOS
switch "-e",
description: "Execute the provided string argument as a script."
switch :verbose
switch :debug
end
end
def ruby
ruby_args.parse
safe_system ENV["HOMEBREW_RUBY_PATH"],
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
"-rglobal", "-rdev-cmd/irb",
*ARGV
end
end