From f6cccc5f482f84ea9d5855b853b90359586ac80c Mon Sep 17 00:00:00 2001 From: s-ol Date: Fri, 8 Jan 2021 14:41:37 +0100 Subject: copilot/cli: colorize output linewise --- alv/copilot/cli.moon | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/alv/copilot/cli.moon b/alv/copilot/cli.moon index e4e633a..14bfd6b 100644 --- a/alv/copilot/cli.moon +++ b/alv/copilot/cli.moon @@ -7,12 +7,19 @@ import parse_args, Copilot from require 'alv.copilot.base' import sleep from require 'system' class ColorLogger extends Logger + new: (...) => + super ... + @time_pref = '' + set_time: (time) => super time - @stream\write switch time + @time_pref = switch time when 'eval' then '\27[92m' when 'run' then '\27[0m' + put: (msg) => + super @time_pref .. msg + class CLICopilot extends Copilot new: (arg) => super parse_args arg, { nocolor: false, 'udp-server': false } -- cgit v1.2.3