Tetra: refactor main

Use codegangsta/cli. Add subcommands for various tasks.