class Railgen::CLI

Public Class Methods

new(argv) click to toggle source
# File lib/railgen/cli.rb, line 6
def initialize(argv)
  @options = options(argv)
end

Public Instance Methods

exec() click to toggle source
# File lib/railgen/cli.rb, line 10
def exec
  if @options[:command].nil?
    puts "command not found"
  else
    eval "#{@options[:command]}.exec(@options)"
  end
end

Private Instance Methods

options(argv) click to toggle source
# File lib/railgen/cli.rb, line 20
def options(argv)
  option = {}
  op = OptionParser.new
  op.on('-t','--target VAL','target directory'){ |v| option[:target] = v }
  op.permute!(argv)
  option[:command] = Rinne.camelize(argv.shift) unless argv.empty?
  option[:namespace] = Rinne.camelize(argv.shift) unless argv.empty?
  option
end