Hi Ricardo, I think I am done with basic changes for 4th task. File is attached. As mentioned in IRC output is in escape code sequence when I tried in REPL.
> I am done with 2nd task out of given 4 tasks and that was included in my > previous patch. > I am currently working on 4th task. I am able to filter lines. I am trying out to*only* filter lines when “guix package” is used but not when “guix build” by adding other port. ---- Thanks!! Sahithi
(use-modules (ice-9 match) ; need this for âmatch-lambdaâ (srfi srfi-1) (srfi srfi-26)) ; need this for âanyâ (define str "phase foo failed after 100 seconds") ;; Each list item in âpatternsâ is a regular expression followed by a ;; number of colours. (let ((patterns '(("^(starting phase )(.*)" BLUE GREEN) ("^(phase)(.*)(succeeded after)(.*)(seconds)" GREEN BLUE GREEN BLUE GREEN) ("^(phase)(.*)(failed after)(.*)(seconds)" RED BLUE RED BLUE RED)))) ;; See if âanyâ of the patterns matches, i.e. returns a string and ;; not just #f. We use âmatch-lambdaâ to bind the pattern to the ;; variable âpatternâ and the list of colours to the variable ;; âcolorsâ. (or (any (match-lambda ((pattern . colors) ;; TODO: use string-match, match:count, match:substring, ;; colorize-string, and=>, etc to see if a pattern matches ;; and to transform the string according to âcolorsâ. ;; If the pattern does not match return #f to ;; automatically try the next, thanks to âanyâ. ;;(colorize-string (match:substring (match:count (string-match pattern str))) colors) (and=> (string-match pattern str) (lambda (m) ; (colorize-string (map match:substring m (iota (- (match:count m) 1) 1) colors))) ;(map (cut match:substring m <>) (iota (- (match:count m) 1) 1)))) (string-join (map (lambda (n color) (colorize-string (match:substring m n) color)) (iota (- (match:count m) 1) 1) colors)))) )) patterns) ;; Nothing matched, so return the string without changes. str))