34 lines
669 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "ostruct"
module Homebrew
module CLI
class Args < OpenStruct
# undefine tap to allow --tap argument
undef tap
def initialize(argv:)
super
@argv = argv
end
2019-08-18 23:34:26 +05:30
def to_cli_option(name)
if name.length == 2
"-#{name.tr("?", "")}"
else
"--#{name.tr("_", "-").tr("?", "")}"
end
end
def options_only
to_h.keys
.map(&:to_s)
.reject { |name| %w[argv remaining].include?(name) }
.map(&method(:to_cli_option))
.select { |arg| arg.start_with?("-") }
end
end
end
end