diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-05-14 12:52:43 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 2e606318721beb31fc5ae3babc4b98c8289b2e80 (patch) | |
| tree | ba9df20ddd26fd322462208779f0d8acd3e6f662 | |
| parent | add website to version.moon, update rockspec (diff) | |
| download | alive-2e606318721beb31fc5ae3babc4b98c8289b2e80.tar.gz alive-2e606318721beb31fc5ae3babc4b98c8289b2e80.zip | |
colorize evaltime output
| -rwxr-xr-x | bin/alv | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -2,18 +2,31 @@ import Copilot, Logger from require 'alv' import sleep from require 'system' -arguments, key = {} +class ColorLogger extends Logger + set_time: (time) => + super time + @stream\write switch time + when 'eval' then '\27[92m' + when 'run' then '\27[0m' + +arguments, key = { nocolor: false } for a in *arg - if match = a\match '^%-%-(.*)' - key = match - arguments[key] = true - elseif key + if key arguments[key] = a key = nil + else if match = a\match '^%-%-(.*)' + if 'bool' == type arguments[key] + arguments[key] = true + else + key = match else table.insert arguments, a +assert not key, "option value missing" -Logger\init arguments.log +if arguments.nocolor + Logger\init arguments.log +else + ColorLogger\init arguments.log assert arguments[1], "no filename given" copilot = Copilot arguments[1] |
