2019-09-29 20:37:39 +03:00
|
|
|
module term
|
|
|
|
|
2019-10-10 20:08:36 +03:00
|
|
|
import os
|
|
|
|
|
2019-09-29 20:37:39 +03:00
|
|
|
pub fn can_show_color_on_stdout() bool {
|
2019-10-10 20:08:36 +03:00
|
|
|
return is_atty(1) && os.getenv('TERM') != 'dumb'
|
2019-09-29 20:37:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn can_show_color_on_stderr() bool {
|
2019-10-10 20:08:36 +03:00
|
|
|
return is_atty(2) && os.getenv('TERM') != 'dumb'
|
2019-09-29 20:37:39 +03:00
|
|
|
}
|
2019-10-07 08:51:26 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
|
|
|
pub fn ok_message(s string) string {
|
|
|
|
return if can_show_color_on_stdout() {
|
|
|
|
green( s )
|
|
|
|
}else{
|
|
|
|
s
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn fail_message(s string) string {
|
|
|
|
return if can_show_color_on_stdout() {
|
|
|
|
red( s )
|
|
|
|
}else{
|
|
|
|
s
|
|
|
|
}
|
|
|
|
}
|