Sha256: 1239ae2f31371c1089c27a24a9aee6605821f8ff40facd5b81c475511a4aaf8a

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require "thor"
require "thor/group"
require "pry"
require "thin"

module Perkins
  class CLI < Thor
    include Thor::Actions
    include Perkins::ThorUtils

    STATUS_TYPES = {:success          => 0,
                    :general_error    => 1,
                    :not_supported    => 3,
                    :not_found        => 4,
                    :incorrect_usage  => 64,
                    }

    no_commands {
      def cli_error(message, exit_status=nil)
        $stderr.puts message
        exit_status = STATUS_TYPES[exit_status] if exit_status.is_a?(Symbol)
        exit(exit_status || 1)
      end
    }

    ### TODO: When these commands list grows big, we need to move them into a seperate commands.rb file
    map %w(--version -v) => 'info'
    desc "info", "information about Perkins::Client::Generator."
    def info
      say "Version #{::Perkins::VERSION}"
    end

    map %w(s) => 'server'
    desc "server ", "run Perkins app"
    method_option :host, :default => "0.0.0.0"
    method_option :port, :default => 9292
    method_option :e, :default => "development"
    def server(config)
      #::Perkins::Server.app = eval(File.open(options.config_file).read)
      ::Perkins::Server.start(config, options)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perkins-0.0.5 lib/perkins/cli.rb
perkins-0.0.3 lib/perkins/cli.rb
perkins-0.0.2 lib/perkins/cli.rb