Sha256: 9021ed4d8e3879283055784189ff90d6cea1298155c3b19d827f66d63743ce6e

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'thor'
require 'penchant'
require 'fileutils'

class PenchantCLI < Thor
  include Thor::Actions
  source_root File.expand_path('../..', __FILE__)

  desc "install", "Copy the common scripts to the project"
  method_options :dir => 'script'
  def install
    directory 'template/script', options[:dir]
    Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) }
  end

  desc "convert", "Make an existing project Penchant-isized"
  method_options :dir => 'script'
  def convert
    install
    FileUtils.mv 'Gemfile', 'Gemfile.erb'
    gemfile(:remote)
  end

  desc "gemfile ENV", "Switch the gemfile environment, or rebuild the current environment if not given"
  def gemfile(env = get_current_env)
    if env
      puts "[penchant] Rebunding for #{env} environment..."
      Penchant::Gemfile.do_full_env_switch!(env)
    end

    gemfile = Penchant::Gemfile.new
    if !gemfile.has_gemfile?
      puts "No Gemfile or Gemfile.erb, exiting."
      exit 1
    end
    system %{bundle}
  end

  desc "gemfile-env", "Get the gemfile environment"
  def gemfile_env
    puts get_current_env
  end

  no_tasks do
    def get_current_env
      gemfile = Penchant::Gemfile.new
      gemfile.environment
    end
  end

  default_task :gemfile
end

PenchantCLI.start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
penchant-0.0.3 bin/penchant