ruby/trema/command/kill.rb in trema-0.2.0 vs ruby/trema/command/kill.rb in trema-0.2.1

- old
+ new

@@ -30,11 +30,11 @@ include Trema::Util def kill options = OptionParser.new - options.banner = "Usage: #{ $PROGRAM_NAME } kill NAME [OPTIONS ...]" + options.banner = "Usage: trema kill NAME [OPTIONS ...]" options.on( "-h", "--help" ) do puts options.to_s exit 0 end @@ -48,16 +48,25 @@ # [FIXME] Trema apps does not appear in context.apps. why? pid_file = File.join( Trema.pid, "#{ ARGV[ 0 ] }.pid" ) if FileTest.exist?( pid_file ) Trema::Process.read( pid_file ).kill! + return end host = context.hosts[ ARGV[ 0 ] ] - host.shutdown! if host + if host + host.shutdown + return + end switch = context.switches[ ARGV[ 0 ] ] - switch.shutdown! if switch + if switch + switch.shutdown + return + end + + raise "Unknown name: #{ ARGV[ 0 ] }" # [TODO] kill a link by its name. Needs a good naming convension for link. end end end