cmdline: add internal wrappers for terminal handling