Module: Atlasq::Command

Defined in:
lib/atlasq/command.rb,
lib/atlasq/command/any.rb,
lib/atlasq/command/base.rb,
lib/atlasq/command/help.rb,
lib/atlasq/command/money.rb,
lib/atlasq/command/usage.rb,
lib/atlasq/command/region.rb,
lib/atlasq/command/country.rb,
lib/atlasq/command/version.rb,
lib/atlasq/command/language.rb

Defined Under Namespace

Classes: Any, Base, Country, Help, Language, Money, Options, Region, Usage, Version

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Atlasq::Command::Options

Parameters:

  • args (Array<String>)

    command line arguments

Returns:



20
21
22
23
24
25
26
# File 'lib/atlasq/command.rb', line 20

def self.parse(args)
  command = parse_command(args.first)
  args.shift unless command.to_s == "Atlasq::Command::Any"
  args.map!(&:strip)

  Options.new(command: command, args: args).freeze
end

.parse_command(command) ⇒ Atlasq::Command::Base

Parameters:

  • command (String)

Returns:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/atlasq/command.rb', line 30

def self.parse_command(command)
  case command
  when "-c", "--country", "--countries"
    Country
  when "-l", "--language", "--languages"
    Language
  when "-r", "--region", "--regions"
    Region
  when "-m", "--money"
    Money
  when "-v", "--version"
    Version
  when "-h", "--help"
    Help
  when nil
    Usage
  else
    Any
  end
end