Standardise script main()

Allow scripts to be invoked with command line options from within
Python, such as <module>.main('-simulate')

Use new handle_args, and process global arguments before local arguments.

Also add docstrings to main() functions.

Not ready to be standardised:
  makecat
  casechecker
  data_ingestion

Change-Id: I828ba3cf155fb6d3e052564d20768fdf9c3acc95
Merge "Standardise script main()"