Sha256: dd41608e8ea5b1113cac9d1f24838e1071c2bee14e2bc9fd93f1dde41041bb91

Contents?: true

Size: 1.72 KB

Versions: 16

Compression:

Stored size: 1.72 KB

Contents

require 'thor'
require 'thor/group'
require 'erb'

module Golf

  class CLI < Thor
    include Thor::Actions
    
    def self.source_root
      File.expand_path("../../../", __FILE__)
    end

    desc "new [NAME] (optional)[TEMPLATE]", "Creates new, rack-based golf app, takes NAME and optionally TEMPLATE [twitter, sinatra, rails]"
    def new(name, template = false)
      unless template
        directory("templates/new", name)
      else
        directory("templates/#{template}", name)
      end
    end
    
    desc "raw", "Dumps a raw hello world golfapp into current dir"
    def raw
      directory("templates/raw", "golfapp")
    end
    
    desc "generate [TYPE] [NAME]", "Generate stub code of TYPE for your already existing golfapp [component, plugin, script]"
    def generate(type, name)
      case type
        when "component"
        if name.include?('.')
          component_name = name.split('.').last
          package_name = name.gsub('.','/').split('/')[0...-1].join('/')
          create_file "golfapp/components/#{package_name}/#{component_name}/#{component_name}.html" do
            File.read(File.expand_path("../../../templates/component/Component.html", __FILE__))
          end
        else
          create_file "golfapp/components/#{name}/#{name}.html" do
            File.read(File.expand_path("../../../templates/component/Component.html", __FILE__))
          end
        end
      end
    end

    desc "server", "Run the golf app"
    def server
      `rackup`
    end
    
    desc "compile [DESTINATION]", "Compile the app into a directory"
    def compile(dir)
      Golf::Compiler.compile!
    end
    
    desc "version", "Output the version number"
    def version
      puts Golf::VERSION
    end


  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
golf-0.4.12 lib/golf/cli.rb
golf-0.4.11 lib/golf/cli.rb
golf-0.4.10 lib/golf/cli.rb
golf-0.4.9 lib/golf/cli.rb
golf-0.4.8 lib/golf/cli.rb
golf-0.4.7 lib/golf/cli.rb
golf-0.4.6 lib/golf/cli.rb
golf-0.4.5 lib/golf/cli.rb
golf-0.4.4 lib/golf/cli.rb
golf-0.4.3 lib/golf/cli.rb
golf-0.4.2 lib/golf/cli.rb
golf-0.4.1 lib/golf/cli.rb
golf-0.4.0 lib/golf/cli.rb
golf-0.3.9 lib/golf/cli.rb
golf-0.3.8 lib/golf/cli.rb
golf-0.3.7 lib/golf/cli.rb