Add flag support to code gen