class Scm::Workflow::Utils::CommandDispatcher
Constants
- EX_INVALCMD
- EX_NOCMD
Public Class Methods
new(rootScriptAbsLocation, rootScriptName)
click to toggle source
# File lib/utils/command-dispatcher.rb, line 19 def initialize(rootScriptAbsLocation, rootScriptName) @rootScriptAbsLocation = rootScriptAbsLocation @rootScriptName = rootScriptName @commandPrefix = rootScriptAbsLocation + '/' + rootScriptName + '-'; end
Public Instance Methods
dispatchCommand(cmd, *arguments)
click to toggle source
# File lib/utils/command-dispatcher.rb, line 37 def dispatchCommand(cmd, *arguments) raise ArgumentError.new(EX_NOCMD) if cmd == nil raise ArgumentError.new("#{cmd} " + EX_INVALCMD) unless isValid?(cmd) exec(@commandPrefix + cmd, *arguments) end
isValid?(command)
click to toggle source
# File lib/utils/command-dispatcher.rb, line 47 def isValid?(command) return false if (!File.exists?(@commandPrefix + command)) return true end
usage()
click to toggle source
# File lib/utils/command-dispatcher.rb, line 27 def usage() Dir.glob(@commandPrefix + '*').each do |f| help = `#{f} --usage` command = File.basename(f).gsub!( "-", " " ) $stdout.puts command.ljust(25) + " : " + help end end