class CDQ::CreateAction

Constants

HELP_TEXT

Public Instance Methods

option_parser() click to toggle source
Calls superclass method CDQ::CommandLine#option_parser
# File lib/cdq/cli.rb, line 121
def option_parser
  super(HELP_TEXT).tap do |opts|
    opts.program_name = "cdq create"

    opts.on("-d", "--dry-run", "Do a Dry Run") do
      @dry_run = "dry_run"
    end
  end
end
run() click to toggle source
# File lib/cdq/cli.rb, line 131
def run
  opts = option_parser
  opts.order!

  object = ARGV.shift

  unless singleton_options_passed
    case object
    when 'model'
      model_name = ARGV.shift
      if model_name

        #camelized = model_name.gsub(/[A-Z]/) { |m| "_#{m.downcase}" }.gsub
        CDQ::Generator.new(@dry_run).create('model', model_name)
      else
        puts "Please supply a model name"
        puts opts
      end
    else
      puts "Invalid object type: #{object}"
      puts opts
    end
  end
end