implement server mode, simplify choosing cli vs. server mode