739: def run!(argv=[], stdin=STDIN)
740: return if has_run?
741: @@has_run = true
742: raise NoCommandsDefined.new if commands.empty?
743:
744: global_options, cmd_name, command_options, argv = process_arguments(argv)
745: stdin = (defined? @@stdin_block) ? @@stdin_block.call(stdin, []) : stdin
746:
747: command_obj = get_command(cmd_name)
748: command_obj.prepare(cmd_name, argv, stdin, global_options, command_options)
749:
750:
751: @@before_block.call(command_obj) if defined? @@before_block
752:
753:
754: @@captured = capture? ? capture_io(@@capture) { command_obj.call } : command_obj.call
755:
756:
757: @@after_block.call(command_obj) if defined? @@after_block
758:
759: rescue OptionParser::InvalidOption => ex
760: raise Drydock::InvalidArgument.new(ex.args)
761: rescue OptionParser::MissingArgument => ex
762: raise Drydock::MissingArgument.new(ex.args)
763: end