Use Cmd module

Use a command module instead of the big if-else block.

If you feel this doesn't fit, feel free to ignore. Might be worth factoring out the command class at some point.