factor out flag parsing from enormous NinjaMain()
simplify some ifdefs
refactor ninja main() into a struct with methods

This removes the ugly Globals struct, and the ResetState() hack.
This also eliminates the only goto!