Run main function once before all subcommands

The main function runs just a single time, before all subucommands are
called in order. Resolves #33 where main was called multiple times, once
before each subcommand.