WIP: CLI client - factor out client library