class Swa::CLI::MainCommand

Constants

RESOURCE_PREFIXES_BY_SERVICE

Protected Instance Methods

parse_parameters() click to toggle source
Calls superclass method
# File lib/swa/cli/main_command.rb, line 33
def parse_parameters
  case remaining_arguments.first
  when /^(\w+)-/
    subcommand = subcommand_for_prefix($1)
    remaining_arguments.unshift(subcommand) if subcommand
  when %r{^s3://([^/]+)/(.+/)?$}
    remaining_arguments[0, 1] = ["s3", "bucket", $1, "objects", "--prefix", $2]
  when %r{^s3://([^/]+)/(.+)\*$}
    remaining_arguments[0, 1] = ["s3", "bucket", $1, "objects", "--prefix", $2]
  when %r{^s3://([^/]+)/(.+)$}
    remaining_arguments[0, 1] = ["s3", "bucket", $1, "object", $2]
  when %r{^s3://([^/]+)$}
    remaining_arguments[0, 1] = ["s3", "bucket", $1]
  end
  super
end
subcommand_for_prefix(prefix) click to toggle source
# File lib/swa/cli/main_command.rb, line 27
def subcommand_for_prefix(prefix)
  RESOURCE_PREFIXES_BY_SERVICE.each do |subcommand, prefixes|
    return subcommand if prefixes.member?(prefix)
  end
end