class Brightbox::Legacy::ArgsAdjuster
This is a simple class to take the ARGV array and inject a command in the correct position (after global options but before anything else)
Public Class Methods
Source
# File lib/brightbox-cli/legacy/args_adjuster.rb, line 9 def initialize(args) @args = args end
Public Instance Methods
Source
# File lib/brightbox-cli/legacy/args_adjuster.rb, line 15 def for_command(command) @globals = [] parser = OptionParser.new do |opts| opts.on("-v", "--version") { |_op| @globals << "-v" } opts.on("-s", "--simple") { |_op| @globals << "-s" } opts.on("-k", "--insecure") { |_op| @globals << "-k" } opts.on("-c", "--client CLIENT") { |op| @globals << "-c" << op } opts.on("--account ACCOUNT") { |op| @globals << "--account" << op } end remaining = parser.order(@args) [] + @globals + [command] + remaining end
@param [String] command The command is insert @return [Array<String>]