Cleanup: simplify flag parsing and merge into mflag

* Refactor and document the flag parsing API in `opts`
* Merge it into `mflag` to expose a unified flag-parsing interface
* This interface is basically an augmented version of the standard `flag`

This depends on #7506. Please review that first.