2 (member "--no-color" *posix-argv
* :test
#'equal
))
4 (defvar *color-error
* nil
)
7 (defun %output-colored-text
(text color
&key bold
)
8 (declare (ignore text color bold
)))
9 (let ((file #-win32
"colorize-control-codes.lisp"
10 #+win32
"colorize-windows-console.lisp"))
11 (handler-case (load file
)
14 (format nil
"Error while loading ~a:~% ~a"
15 (enough-namestring file
)
19 (let* ((stream (sb-impl::stream-output-stream
*standard-output
*))
20 (fd (and (sb-sys:fd-stream-p stream
)
21 (sb-sys:fd-stream-fd stream
))))
23 (plusp (sb-unix:unix-isatty fd
)))))
25 (defun present-coloring-error (error)
26 (format t
"~a~%" error
)
27 (format t
"Switching off colored output,~%~
28 it can be turned off by passing --no-color~%~%")
31 (defun output-colored-text (kind text
33 (cond ((or (not (is-tty))
37 (present-coloring-error *color-error
*)
46 (%output-colored-text text
:red
:bold t
))
47 ((:unexpected-success
)
48 (%output-colored-text text
:green
))
52 (present-coloring-error
53 (format nil
"Error while printing colored text:~% ~a"
55 (write-string text
)))))
56 (write-string (make-string (max 0 (- align
(length text
)))
57 :initial-element
#\Space
)))