Sha256: 666f200b29dfae1ebb4cc744287e9443087590015b5bc1326af59465d760adf6

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

require 'bundler/setup'
require 'thor'

class CLI < Thor
  include Thor::Actions
  
  desc "new PROJECT_NAME", "generates a new project."
  def new(name)
    directory("project", name)
    
    say "Bundling Gems...."
    `cd #{name} ; bundle -j 4`
  end
  
  desc "console", "run the console on the project in the current directory"
  def console
    require 'volt/console'
    Console.start
  end

  desc "server", "run the server on the project in the current directory"
  def server
    require 'thin'
    require 'fileutils'

    # If we're in a Volt project, clear the temp directory
    # TODO: this is a work around for a bug when switching between
    # source maps and non-source maps.
    if File.exists?("config.ru") && File.exists?("Gemfile")
      FileUtils.rm_rf("tmp/.")
    end

    ENV['SERVER'] = 'true'
    Thin::Runner.new(['start']).run!
  end
  
  desc "gem GEM", "Creates a component gem where you can share a component"
  method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
  method_option :test, :type => :string, :lazy_default => 'rspec', :aliases => '-t', :banner => "Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported."
  method_option :edit, :type => :string, :aliases => "-e",
                :lazy_default => [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? },
                :required => false, :banner => "/path/to/your/editor",
                :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
  def gem(name)
    require 'volt/cli/new_gem'
    
    NewGem.new(self, name, options)
  end  
  
  def self.source_root
    File.expand_path(File.join(File.dirname(__FILE__), '../../templates'))
  end
end

CLI.start(ARGV)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
volt-0.4.0 lib/volt/cli.rb
volt-0.3.9 lib/volt/cli.rb
volt-0.3.8 lib/volt/cli.rb
volt-0.3.7 lib/volt/cli.rb
volt-0.3.6 lib/volt/cli.rb