I'm writing a debugger for a Z80-emulator we are writing in a school project, using Java. The debugger reads a command from the user, executes it, reads another command, etc.
Commands can either be argument less, have optional arguments, or take an unlimited amount of arguments. Arguments are mostly integers, but occasionally they're strings.
Currently, we're using the Scanner-class for reading and parsing input. The read-method looks kinda like like this (I'm writing this off the top of my head, not paying attention to syntax nor correctness).
This was a kludge written in the beginning of the project, which quickly got out of hand as we added more and more commands to the debugger.
The major issues I have with this code is the large amount of repetition, the highlevel of if/else-nestedness, and the all around uglyness.
I would like suggestions on how to make this code more beautiful and modular, and what kind of patterns that are suitable for this kind of program.
I would also like more general suggestions on code style.