Separate CLI into a library