simplify glog.nim

This commit is contained in:
Rasmus Moorats 2023-09-30 14:43:37 +03:00
parent 981eec9a30
commit 5dccc81116
Signed by: xx
GPG key ID: FE14255A6AE7241C

View file

@ -1,11 +1,6 @@
import std/[os, strformat, strutils]
import lib/procs
const
esc = "\x1B["
reset = esc & "0m"
grey = reset & esc & "2m"
let
gitArgs = @[
"log",
@ -19,8 +14,8 @@ let
for line in rawOutput.splitLines(keepEol = true):
let
keys = line.split(" ", maxsplit = 3)
if keys.len < 4 or keys[0] != "*":
keys = line.split(" ", maxsplit = 2)
if keys.len < 3 or keys[0] != "*":
stdout.write line
stdout.flushFile
continue
@ -36,5 +31,5 @@ for line in rawOutput.splitLines(keepEol = true):
of "N": "2" # no signature
else: "0" # this shouldn't really happen
stdout.write &"* {esc}{col}m{keys[1]} {grey}{keys[2]}{reset} {keys[3]}"
stdout.write &"* \x1B[{col}m{keys[1]}\x1B[0m {keys[2]}"
stdout.flushFile