Sha256: a1733e778d848165b78536efd4511698fa62f2e29108fff08acf0ae57769f18c

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby

# NOTE: If you would like to execute this file as a developer
#       but not install the CSD gem, you can use this command:
#       ruby -I path/to/csd/lib path/to/csd/bin/ai

# First, let's load the RubyGems framework and the CSD gem.
# Even though RubyGems is already loaded for Ruby >= 1.9,
# we want to go sure here and load it to provide robustness
require 'rubygems'
require 'csd'

begin
  # Running the CSD library and telling it who started it
  CSD.bootstrap :executable => 'ai'
rescue CSD::Error::CSDError => e
  # Here we catch CSD internal errors and exit with the propriate status code
  # We output the error message only for status codes 50 and higher, because they are rather severe
  if e.status_code >= 50
    CSD.ui.error e.message
    if e.status_code < 200
      puts
      puts "  \e[31mPlease report bugs at:\e[0m \e[36mhttp://github.com/csd/csd/issues\e[0m"
      puts
    end
  end
  exit e.status_code
rescue Interrupt
  # Lastly, close the AI gracefully on abnormal termination
  CSD.ui.separator
  CSD.ui.info "Quitting the AI...".red
  exit 1
rescue ScriptError => e
  puts "\e[31m\e[5mINTERNAL SCRIPT ERROR: \e[0m\e[31m#{e}\e[0m"
  puts
  puts e.backtrace.join("\n")
  puts
  puts "  \e[31m\e[1mPlease report errors at:\e[0m \e[36mhttp://github.com/csd/csd/issues\e[0m"
  puts
rescue StandardError => e
  puts "\e[31m\e[5mINTERNAL ERROR: \e[0m\e[31m#{e}\e[0m"
  puts
  puts e.backtrace.join("\n")
  puts
  puts "  \e[31m\e[1mPlease report errors at:\e[0m \e[36mhttp://github.com/csd/csd/issues\e[0m"
  puts
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
csd-0.4.3 bin/ai
csd-0.4.2 bin/ai
csd-0.4.1 bin/ai
csd-0.4.0 bin/ai
csd-0.3.7 bin/ai
csd-0.3.6 bin/ai
csd-0.3.5 bin/ai
csd-0.3.4 bin/ai
csd-0.3.3 bin/ai
csd-0.3.2 bin/ai
csd-0.3.1 bin/ai
csd-0.3.0 bin/ai
csd-0.2.2 bin/ai
csd-0.2.1 bin/ai
csd-0.2.0 bin/ai