Extract CLI module

To separate CLI and library - see #2