diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-05-14 12:52:43 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-05-14 13:02:53 +0000 |
| commit | d466c5ebbed6bea352cc325d06868c39f446c177 (patch) | |
| tree | f420753305d3db6b6c541b2a9a0f45ac7fc3d85a /bin | |
| parent | add website to version.moon, update rockspec (diff) | |
| download | alive-d466c5ebbed6bea352cc325d06868c39f446c177.tar.gz alive-d466c5ebbed6bea352cc325d06868c39f446c177.zip | |
colorize evaltime output
Diffstat (limited to 'bin')
| -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] |
