Class: Geert::CLI

Inherits:
OptionsParser show all
Defined in:
lib/geert/cli.rb

Instance Attribute Summary

Attributes inherited from OptionsParser

#arguments, #stdout

Instance Method Summary collapse

Methods inherited from OptionsParser

after, before, execute, #initialize, options, #options, parse, #parse, parse_options, #separator

Constructor Details

This class inherits a constructor from OptionsParser

Instance Method Details



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/geert/cli.rb', line 7

def banner
  <<-BANNER.gsub(/^ +/,'')
  Find foreign keys in ActiveRecord and create a migration to add them.

  Go to your Rails directory, or optionally provide the path to it.

  Please remember to read the readme, for further instructions.

  Usage: geert [options] [DIRECTORY]
  e.g. geert ~/projects/myapp
  BANNER
end

#directoryObject



41
42
43
# File 'lib/geert/cli.rb', line 41

def directory
  arguments[-1] || Dir.pwd
end

#environmentObject



37
38
39
# File 'lib/geert/cli.rb', line 37

def environment
  File.join(directory, "config", "environment.rb")
end

#no_rails!Object



32
33
34
35
# File 'lib/geert/cli.rb', line 32

def no_rails!
  stdout.puts "Error: #{directory} is not a valid Rails application"
  halt!
end