Merge code from whateversh (and some other things)

This merges most of the code from [whateversh](http://github.com/dgelessus/whateversh). In a few cases I simply overwrote the existing commands, because the corresponding whateversh version had more functionality.

Also changed all commands so they will no longer run immediately when imported for some reason, by moving the main command code into a `main` function and adding an `if __name__ == "__main__"`. THere are also various other minor code changes/fixes/simplifications that should not affect the end user (significantly).