Sha256: b29429b5416fded439c5a3f17f252cda9c73a03ff9da1b1d3c5d715750acd6be
Contents?: true
Size: 1.11 KB
Versions: 14
Compression:
Stored size: 1.11 KB
Contents
require "optparse" class Ppl::Application::Shell attr_writer :router def run(input, output) outcome = false begin command = select_command(input) prepare_command(command, input) outcome = execute_command(command, input, output) rescue OptionParser::InvalidOption output.error($!) output.error(@optparse.to_s) rescue OptionParser::MissingArgument output.error($!) output.error(@optparse.to_s) rescue Ppl::Error::IncorrectUsage output.error($!) output.error(@optparse.to_s) rescue output.error("ppl: " + $!.message) outcome = false end return outcome end private def select_command(input) @router.route(input.arguments.shift) end def prepare_command(command, input) if !command.nil? @optparse = OptionParser.new do |parser| command.options(parser, input.options) end @optparse.parse!(input.arguments) end end def execute_command(command, input, output) outcome = false if !command.nil? outcome = command.execute(input, output) end return outcome end end
Version data entries
14 entries across 14 versions & 1 rubygems