lib/csd.rb in csd-0.1.9 vs lib/csd.rb in csd-0.1.10
- old
+ new
@@ -6,33 +6,41 @@
# The CSD namespace is given to the entire gem.
# It stands for Communication Systems Design (see http://www.tslab.ssvl.kth.se/csd).
#
module CSD
class << self
-
+
# This String holds the name of the executable the user used to bootstrap this gem
attr_reader :executable
-
+
# This method "runs" the whole CSD gem, so to speak.
#
def bootstrap(options={})
@executable = options[:executable]
Options.parse!
respond_to_incomplete_arguments
+ UI.debug "#{self}.bootstrap initializes the task #{Options.action.enquote} of the application #{Applications.current.name.to_s.enquote} now"
Applications.current.instance.send("#{Options.action}".to_sym)
end
-
+
private
-
+
# This method check the arguments the user has provided and terminates the AI with
# some helpful message if the arguments are invalid.
#
def respond_to_incomplete_arguments
- choose_application unless Applications.current
- choose_action unless Options.valid_action?
+ if !Applications.current and ARGV.include?('update')
+ # Updating the AI
+ UI.info "Updating the AI to the newest version".green.bold
+ Cmd.run "sudo gem update csd", :announce_pwd => false, :verbose => true
+ exit # The only smooth status code 0 exit in this whole application :)
+ else
+ choose_application unless Applications.current
+ choose_action unless Options.valid_action?
+ end
end
-
+
# This methods lists all available applications
#
def choose_application
UI.separator
UI.info ' Welcome to the Automated Installer.'.green.bold
@@ -72,7 +80,6 @@
UI.warn "You did not specify a valid task name."
raise Error::Argument::NoAction
end
end
-
end