mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
e64609387d
* isConsole moved to builtin is_atty function * Windows console initialization moved to builtin.init
30 lines
475 B
V
30 lines
475 B
V
module term
|
|
|
|
import os
|
|
|
|
pub fn can_show_color_on_stdout() bool {
|
|
return is_atty(1) && os.getenv('TERM') != 'dumb'
|
|
}
|
|
|
|
pub fn can_show_color_on_stderr() bool {
|
|
return is_atty(2) && os.getenv('TERM') != 'dumb'
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
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
|
|
}
|
|
}
|