generate command code macros automatically