cli: move the implementation of the CLI functions to a separate module

This will facilitate use from the sparse_dd frontend.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>