Sha256: 69bf90ce273a082663455935984d351959dde43d265c61719dec3d849ca8c39e

Contents?: true

Size: 2 KB

Versions: 1

Compression:

Stored size: 2 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'methadone'
require 'clearsight.rb'

class App
  include Methadone::Main
  include Methadone::CLILogging
  include Methadone::SH

  # Create command line options here. Don't forget to document
  # them below in the show_help method.
  main do |command, *args|
    case command.to_s.to_sym
    when :deploy then CS::Deploy.deploy(args)
    when :update then update
    when :help then show_help
    when :killrails then killrails(args.first || 3000)
    when :sshify then sshify(args.first, options[:key] || "id_rsa.pub")
    when :mm then CS::Middleman.new(args).run
    else
      puts "Invalid command."
      show_help
    end
  end
  on("--key VALUE")
  on("-k VALUE", "--key")

  def self.show_help
    puts "USAGE:"
    puts "  deploy <setup>"
    puts "    Deploys or sets up deployment to a remote server. Replaces gitdeploysetup."
    puts "  killrails <port>"
    puts "    Kills a rails server running on the given port. Only works on Linux (so far)."
    puts "  sshify host <-k keyname.pub>"
    puts "    Installs your SSH public key (id_rsa.pub unless you pass a different one) to a remote server (user@host.com)."
    puts "  mm <project>"
    puts "    Initializes a middleman project with the given project name using the ClearSight template."
    puts "  update"
    puts "    Updates the gem. Same as `gem update clearsight`."
  end

  def self.update
    print "Updating."
    start_progress do
      sh "gem update clearsight"
    end
    puts "done."
  end

  def self.killrails(port)
    print "Killing Rails."
    start_progress do
      sh "fuser -n tcp -k #{port}"
    end
    puts "dead."
  end

  def self.sshify(host, keyname)
    puts "Installing SSH key to remote server."
    sh "cat ~/.ssh/#{keyname} | ssh #{host} 'cat >> ~/.ssh/authorized_keys'"
    puts "Installed."
  end

  def self.start_progress
    @t = CS::Timer.new 0.5 do print "." end
    yield
    @t.stop
  end

  arg :args, :optional

  version Clearsight::VERSION

  use_log_level_option

  go!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clearsight-1.0.0 bin/cs