class CDQ::InitAction

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 65
def option_parser
  super(HELP_TEXT).tap do |opts|
    opts.program_name = "cdq init"

    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 75
def run
  opts = option_parser
  opts.order!

  unless singleton_options_passed
    CDQ::Generator.new(@dry_run).create('init')

    print "  \u0394  Checking bundle for cdq... "
    unless system('bundle show cdq')
      print "  \u0394  Adding cdq to Gemfile... "
      File.open("Gemfile", "at") do |gemfile|
        gemfile.puts("gem 'cdq'")
      end
      puts "Done."
    end

    # print "  \u0394  Checking bundle for ruby-xcdm... "
    # unless system('bundle show ruby-xcdm')
    #   print "  \u0394  Adding ruby-xcdm to Gemfile... "
    #   File.open("Gemfile", "at") do |gemfile|
    #     gemfile.puts("gem 'ruby-xcdm'")
    #   end
    #   puts "Done."
    # end

    print "  \u0394  Adding schema:build hook to Rakefile... "
    File.open("Rakefile", "at") do |rakefile|
      rakefile.puts('task :"build:simulator" => :"schema:build"')
    end
    puts "Done."

    puts %{\n  Now edit schemas/0001_initial.rb to define your schema, and you're off and running.  }

  end
end