Pull cmd line adaptor code out into a separate module.
Fixes for core to accept new documents one at a time.