Class: FlywayMigrator::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/flyway_migrator/cli.rb

Overview

The Command Line Interface (CLI) for the gem.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



18
19
20
21
22
23
# File 'lib/flyway_migrator/cli.rb', line 18

def initialize args = [], options = {}, config = {}
  super args, options, config
  @configuration = self.class.configuration
rescue Runcom::Errors::Base => error
  abort error.message
end

Class Method Details

.configurationObject



14
15
16
# File 'lib/flyway_migrator/cli.rb', line 14

def self.configuration
  Runcom::Configuration.new project_name: Identity.name
end

Instance Method Details

#generateObject



31
32
33
34
35
36
37
38
# File 'lib/flyway_migrator/cli.rb', line 31

def generate
  path = configuration.path

  if options.name?
    FlywayMigrator::Migration.generate(options.name)
  else help(:name)
  end
end

#help(task = nil) ⇒ Object



48
49
50
# File 'lib/flyway_migrator/cli.rb', line 48

def help task = nil
  say and super
end

#versionObject



42
43
44
# File 'lib/flyway_migrator/cli.rb', line 42

def version
  say Identity.version_label
end