Class: Aigu::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/aigu/cli.rb

Constant Summary collapse

COMMANDS =
{
  'rails-import' => 'RailsImporter',
  'rails-export' => 'RailsExporter',
  'android-import' => 'AndroidImporter',
  'android-export' => 'AndroidExporter',
  'core-import' => 'CoreImporter',
  'core-export' => 'CoreExporter',
  'ios-import' => 'IOSImporter',
  'ios-export' => 'IOSExporter',
  'ember-import' => 'EmberImporter',
  'ember-export' => 'EmberExporter',
  'ember-pod-import' => 'EmberPodImporter',
  'ember-pod-export' => 'EmberPodExporter',
  'ember-engine-import' => 'EmberEngineImporter',
  'ember-engine-export' => 'EmberEngineExporter'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(env, argv) ⇒ CLI

Returns a new instance of CLI.



20
21
22
23
24
25
26
27
28
# File 'lib/aigu/cli.rb', line 20

def initialize(env, argv)
  @env = env
  @command = argv.first =~ /^[^-]/ ? argv.shift : nil
  @command = @command.tr('_', '-') if @command
  @argv = argv
  @options = {}
  @options = parse_options_from_yaml(@options)
  @options = parse_options_from_arguments(@options)
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/aigu/cli.rb', line 30

def run
  if COMMANDS[@command]
    service_class = Aigu.const_get(COMMANDS[@command])
  else
    puts "The #{@command} command doesn’t exist. Nice try."
    exit 0
  end

  service_object = service_class.new(@options)
  service_object.process!
end