Sha256: 7dd1b19252c99b6337cc1d32af8fd26e86d51efa618239b15b8af8f517695677

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require 'fileutils'
require 'classiccms/version'

module Classiccms
  class Cli
    def self.command(arguments)
      case arguments[0]
      when 'new'    then self.new arguments[1]
      when 'server' then self.server
      when 's'      then self.server
      when '-v' then puts "version #{VERSION}"
      else
        puts "you are so smart! I don't know what you mean! (try using new or server)"
      end
    end

    def self.new(app_name)
      if app_name == nil
        puts 'hmm you are using the command wrong: classicCMS new [app name]'
      elsif File::directory? app_name
        puts 'hmm I think that app already exists!'
      else
        #copy scaffold
        FileUtils.cp_r File.join(File.dirname(__FILE__), "scaffold"),  Dir.pwd + "/#{app_name}"

        #replace database
        mongoid = File.read(File.join(Dir.pwd, app_name, 'config/mongoid.yml')).gsub('$', app_name)
        File.open(File.join(Dir.pwd, app_name, 'config/mongoid.yml'), 'w') do |f|
          f.puts mongoid
        end

        puts "#{app_name} created!"
      end
    end
    def self.server
      #first check if this is actualy an app
      system('rackup')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
classiccms-0.3.7 lib/classiccms/cli.rb
classiccms-0.3.6 lib/classiccms/cli.rb
classiccms-0.3.5 lib/classiccms/cli.rb
classiccms-0.3.4 lib/classiccms/cli.rb
classiccms-0.3.3 lib/classiccms/cli.rb
classiccms-0.3.2 lib/classiccms/cli.rb
classiccms-0.3.1 lib/classiccms/cli.rb