use ui.writeError in lib/cli/cli.js

fixes GH-2254
Merge pull request #2342 from fivetanley/use-ui-write-in-cli

use ui.writeError in lib/cli/cli.js