2 (member "--no-color" *posix-argv
* :test
#'equal
))
4 (defvar *color-error
* nil
)
7 (let ((file #-win32
"colorize-control-codes.lisp"
8 #+win32
"colorize-windows-console.lisp"))
9 (handler-case (load file
)
12 (format nil
"Error while loading ~a:~% ~a"
13 (enough-namestring file
)
17 (let* ((stream (sb-impl::stream-output-stream
*standard-output
*))
18 (fd (and (sb-sys:fd-stream-p stream
)
19 (sb-sys:fd-stream-fd stream
))))
21 (plusp (sb-unix:unix-isatty fd
)))))
23 (defun present-coloring-error (error)
24 (format t
"~a~%" error
)
25 (format t
"Switching off colored output,~%~
26 it can be turned off by passing --no-color~%~%")
29 (defun output-colored-text (kind text
31 (cond ((or (not (is-tty))
35 (present-coloring-error *color-error
*)
44 (%output-colored-text text
:red
:bold t
))
45 ((:unexpected-success
)
46 (%output-colored-text text
:green
))
50 (present-coloring-error
51 (format nil
"Error while printing colored text:~% ~a"
53 (write-string text
)))))
54 (write-string (make-string (max 0 (- align
(length text
)))
55 :initial-element
#\Space
)))