aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-14 12:52:43 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit2e606318721beb31fc5ae3babc4b98c8289b2e80 (patch)
treeba9df20ddd26fd322462208779f0d8acd3e6f662
parentadd website to version.moon, update rockspec (diff)
downloadalive-2e606318721beb31fc5ae3babc4b98c8289b2e80.tar.gz
alive-2e606318721beb31fc5ae3babc4b98c8289b2e80.zip
colorize evaltime output
-rwxr-xr-xbin/alv25
1 files changed, 19 insertions, 6 deletions
diff --git a/bin/alv b/bin/alv
index 02aee7e..272cac3 100755
--- a/bin/alv
+++ b/bin/alv
@@ -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]