Sha256: 0fc016526b3deadacf2710cdd28ec8f0298f2cb474aecff68091c2f22b850506

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

#! /usr/bin/env ruby

require 'clamp'
require 'hashie'
require 'greenscreen/app'

class GreenScreenCommand < Clamp::Command

  option ["-c", "--config"], "FILE", "config file", :attribute_name => :config_file, :default => "~/.greenscreen.yml"

  option ["-p", "--port"], "PORT", "server port", :default => 3000 do |v|
    Integer(v)
  end

  def default_config_file
    ENV["HOME"] + "/.greenscreen.yml"
  end

  def load_config
    @config ||= begin
      signal_usage_error("no such file: #{config_file.inspect}") unless File.exist?(config_file)
      Hashie::Mash.new(YAML.load_file(config_file))
    end
  end

  def execute
    GreenScreen::App.run!(:port => port, :config => load_config)
  end

end

GreenScreenCommand.run

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
greenscreen-0.1.2 bin/greenscreen
greenscreen-0.1.1 bin/greenscreen
greenscreen-0.1.0 bin/greenscreen