Module: Aws::ASMR::Options
- Defined in:
- lib/aws/asmr/options.rb
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/aws/asmr/options.rb', line 19 def parse(args) = {} OptionParser.new do |opts| # opts.banner = "Usage: asmr [options]" opts. = <<~EOS You can use ALIAS to shortcut name input by setting it at #{Aws::ASMR::ROOT}/alias Usage: asmr [options] [command] [arg...] EOS opts.on("-nNAME", "--name=NAME", "Name to perform assume role with ARN or ALIAS") do |name| [:name] = name end opts.on("-h", "--help", "Prints this help") do puts opts exit(0) end opts.on("--version", "Prints version") do [:version] = true end opts.on("--clear", "Clear cache") do [:clear] = true # require "aws/asmr/version" # puts Aws::ASMR::VERSION # exit(0) end end.parse(args) end |
.partition(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/aws/asmr/options.rb', line 6 def partition(args) _idx, asmr_args, command_args = args.reduce([1, [], []]) do |acc,i| idx, _, _ = acc unless i.start_with?('-') idx = 2 acc[0] = idx end acc[idx] << i acc end [asmr_args, command_args] end |