Implement proper command line argument parsing

Also, refactor non-command line oriented code out of scripts/*.py so
that the implementation of each command is available as a loadable
module.  As part of this, refactor the "call_with_client()" function,
which took a callable, made a client, and called the callable with the
client as the first argument; instead, introduce a ClientContext context
manager to do the same job.