Converts to using argparse.

I've attempted to maintain existing behaviour where possible.