Sha256: 9be4df8f33cbd1f4e51e285e9c681c4344bd6b3df2e45782bada98e06594361a

Contents?: true

Size: 985 Bytes

Versions: 4

Compression:

Stored size: 985 Bytes

Contents

require 'thor'
require 'fileutils'
require 'crosstie'

module Crosstie

  class CLI < Thor

    desc 'new my_app', 'create a new rails application'
    def new name
      if File.exist? 'resources.yml'
        FileUtils.mkdir_p '/tmp/crosstie'
        FileUtils.cp 'resources.yml', '/tmp/crosstie/resources.yml'
      end
      cmd = "rails new #{name} --template #{template_path}"
      puts cmd
      system cmd
    end

    desc 'resources', 'create a resources.yml template'
    def resources
      puts 'writing resources.yml'
      File.write 'resources.yml', <<-EOF
article:
  - title:string
  - content:text
comment:
  - article:references
  - content:text
      EOF
    end

    desc 'version', 'print current version'
    def version
      puts "crosstie #{Crosstie::VERSION}"
    end
    map %w(-v --version) => :version

    private

    def template_path
      File.join root, 'base.rb'
    end

    def root
      File.expand_path File.dirname __FILE__
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crosstie-0.0.6 lib/crosstie/cli.rb
crosstie-0.0.5 lib/crosstie/cli.rb
crosstie-0.0.4 lib/crosstie/cli.rb
crosstie-0.0.3 lib/crosstie/cli.rb