Move shell completion things into a separate file

Move (most) things related to shell completion into a separate file from
wman.cpp.  This allows independent refactoring of the different parts.
Also clean up write_man() and the mechanism that invokes it now that it
is only used with the new context mechanism.

Change-Id: Ife0e3e5c64a78b73917123d9b7bdbe121f844ebc