Cleanup: simplify flag parsing and merge into mflag (rebase ++)

this is to get #7551 updated for merge.

I've added the missing non-global validation functions, and rebased 
This is idiomatic for sets and `flAttach` is list of boolean values, not set. It actually can contain "stdout" "false".