bin/ai in csd-0.1.8 vs bin/ai in csd-0.1.9
- old
+ new
@@ -1,23 +1,26 @@
#!/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/tta
-
-# This executable is DEPRECATED
-# Please use 'tta' instead.
-
-puts
-puts "`ai´ is DEPRECATED. Please use `tta´ instead."
-
+# 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
CSD.ui.error e.message unless e.status_code <= 49
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
end
\ No newline at end of file