Simplify the HTTP methods and clean up error handling.

There was a lot of repetition in the methods for coping with what are quite
common error states. This is now handled in one place.
Split up the CLI options code.

It was starting to get a little unwieldy with the amount of options defined in a
single method. The options have now been split up into separate methods.