Remove trailing space after print
Simple solution for command line interface testing

* The priciple is to keep using doctest. We replace '$>' by '>>>' and then
  call subprocess.check_output to call the command line from Python
* All the command line use cases are put into cli.rst and validated using this
  approach