Sha256: a2719b4bb5296969875572a1f358d4d624be30085b91c061346c44f65e237e08

Contents?: true

Size: 1.1 KB

Versions: 11

Compression:

Stored size: 1.1 KB

Contents

require "spring/errors"
require "spring/json"

require "spring/client/command"
require "spring/client/run"
require "spring/client/help"
require "spring/client/binstub"
require "spring/client/stop"
require "spring/client/status"
require "spring/client/rails"
require "spring/client/version"

module Spring
  module Client
    COMMANDS = {
      "help"      => Client::Help,
      "-h"        => Client::Help,
      "--help"    => Client::Help,
      "binstub"   => Client::Binstub,
      "stop"      => Client::Stop,
      "status"    => Client::Status,
      "rails"     => Client::Rails,
      "-v"        => Client::Version,
      "--version" => Client::Version,
    }

    def self.run(args)
      command_for(args.first).call(args)
    rescue CommandNotFound
      Client::Help.call(args)
    rescue ClientError => e
      $stderr.puts e.message
      exit 1
    end

    def self.command_for(name)
      COMMANDS[name] || Client::Run
    end
  end
end

# allow users to add hooks that do not run in the server
# or modify start/stop
if File.exist?("config/spring_client.rb")
  require "./config/spring_client.rb"
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spring-1.6.4 lib/spring/client.rb
spring-1.6.3 lib/spring/client.rb
spring-1.6.2 lib/spring/client.rb
spring-1.6.1 lib/spring/client.rb
spring-1.6.0 lib/spring/client.rb
spring-1.5.0 lib/spring/client.rb
spring-1.4.4 lib/spring/client.rb
spring-1.4.3 lib/spring/client.rb
spring-1.4.2 lib/spring/client.rb
spring-1.4.1 lib/spring/client.rb
spring-1.4.0 lib/spring/client.rb