36 lines
793 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
module_function
def ruby_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`ruby` [`-e`]:
2019-08-06 14:22:24 -04:00
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",
2019-04-30 08:44:35 +01:00
description: "Execute the provided string argument as a script."
switch :verbose
switch :debug
end
end
def ruby
ruby_args.parse
begin
safe_system ENV["HOMEBREW_RUBY_PATH"],
"-I", $LOAD_PATH.join(File::PATH_SEPARATOR),
"-rglobal", "-rdev-cmd/irb",
*ARGV
rescue ErrorDuringExecution => e
exit e.status.exitstatus
end
end
end