Module: EventMachine::Wssh::Exe
- Defined in:
- lib/em/wssh/exe.rb
Class Method Summary collapse
Class Method Details
.command?(cmd) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/em/wssh/exe.rb', line 5 def self.command? cmd return unless /\A\w+\Z/.match cmd cmd=cmd.downcase begin require_relative cmd rescue LoadError return end m=Module.nesting[1].const_get cmd.sub(/^./){|s|s.upcase} rescue nil return unless Module===m and m.respond_to? :go! m end |
.commands ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/em/wssh/exe.rb', line 18 def self.commands m=Module.nesting[1] Hash[ m.constants .map{|n|m.const_get n} .grep(Module) .select{|m| m.respond_to? :go!} .select{|m| m.const_defined? :Title} .map{|m| [m.name.split(/\W+/).last.downcase, m]} .sort_by{|x| x[0]} ] end |
.do! ⇒ Object
31 32 33 34 35 |
# File 'lib/em/wssh/exe.rb', line 31 def self.do! mod = command? ARGV.shift help unless mod mod.go! end |
.help ⇒ Object
37 38 39 40 41 |
# File 'lib/em/wssh/exe.rb', line 37 def self.help require_relative 'help' Help.go! exit end |
.usage ⇒ Object
43 44 45 |
# File 'lib/em/wssh/exe.rb', line 43 def self.usage "Usage: wssh "+File.basename(caller_locations.first.path).sub(/[.][^.]*\Z/, '') end |