merge repeating code for flags in cli