Separate cli from lib

* Separate cli from lib
* Add other encoding support
* Add other end-of-line char support