Module: Drudge::Dispatch::ClassMethods
- Defined in:
- lib/drudge/dispatch.rb
Constant Summary collapse
- Tokenizer =
Drudge::Parsers::Tokenizer
Instance Method Summary collapse
-
#dispatch(command_name = File.basename($0), args = ARGV) ⇒ Object
Runs the CLI with the specified arguments.
Instance Method Details
#dispatch(command_name = File.basename($0), args = ARGV) ⇒ Object
Runs the CLI with the specified arguments
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/drudge/dispatch.rb', line 16 def dispatch(command_name = File.basename($0), args = ARGV) cli_kit = self.new.to_kit(command_name) complete_args = command_name, *args argument_parser = cli_kit.argument_parser _, *command_arguments = argument_parser.parse!(complete_args)[:args] cli_kit.dispatch(*command_arguments) rescue CliError => e puts "#{e.command}: #{e.message}" rescue ParseError => pe $stderr.puts " error: \#{pe.message}:\n\n \#{Tokenizer.untokenize(pe.input)}\n \#{Tokenizer.underline_token(pe.input, \n pe.remaining_input.first)}\n EOS\n\n\nend\n".undent |