diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index 920b8673b846296d9d0d8c00c2b7f42bb36affcb..9522e03e2dfcc311379c76f801d3d0359458c71e 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -190,7 +190,20 @@ help def install(args) command, subcommand, target = args - if subcommand.to_s == 'check' + if subcommand.to_s == 'update' + begin + if up_to_date? + puts "*".green + " hub is up to date" + elsif rubygems? + puts "*".red + " hub is " + "not".bold.underline + " up to date" + else + update + end + rescue Object => e + puts "*".bold.yellow + " error updating hub: #{e.class}" + end + + elsif subcommand.to_s == 'check' begin if up_to_date? puts "*".green + " hub is up to date" @@ -200,13 +213,15 @@ help rescue Object => e puts "*".bold.yellow + " error checking status: #{e.class}" end + else puts <<-output usage: hub install COMMAND [ARGS] Commands: - check Checks if the current installation is up to date - by phoning home. + check Checks if the current installation is up to date + by phoning home. + update Updates hub if a newer version is available. output end @@ -216,7 +231,7 @@ output private # # Helper methods are private so they cannot be invoked - # from the command line + # from the command line. # # Is the current running version of hub up to date?