mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: single line ternary return (#8605)
This commit is contained in:
@@ -29,31 +29,19 @@ pub fn can_show_color_on_stderr() bool {
|
||||
// ok_message returns a colored string with green color.
|
||||
// If colors are not allowed, returns a given string.
|
||||
pub fn ok_message(s string) string {
|
||||
return if can_show_color_on_stdout() {
|
||||
green(' $s ')
|
||||
} else {
|
||||
s
|
||||
}
|
||||
return if can_show_color_on_stdout() { green(' $s ') } else { s }
|
||||
}
|
||||
|
||||
// fail_message returns a colored string with red color.
|
||||
// If colors are not allowed, returns a given string.
|
||||
pub fn fail_message(s string) string {
|
||||
return if can_show_color_on_stdout() {
|
||||
inverse(bg_white(bold(red(' $s '))))
|
||||
} else {
|
||||
s
|
||||
}
|
||||
return if can_show_color_on_stdout() { inverse(bg_white(bold(red(' $s ')))) } else { s }
|
||||
}
|
||||
|
||||
// warn_message returns a colored string with yellow color.
|
||||
// If colors are not allowed, returns a given string.
|
||||
pub fn warn_message(s string) string {
|
||||
return if can_show_color_on_stdout() {
|
||||
bright_yellow(' $s ')
|
||||
} else {
|
||||
s
|
||||
}
|
||||
return if can_show_color_on_stdout() { bright_yellow(' $s ') } else { s }
|
||||
}
|
||||
|
||||
// colorize returns a colored string by running the specified `cfn` over
|
||||
@@ -107,11 +95,7 @@ pub fn header(text string, divider string) string {
|
||||
}
|
||||
|
||||
fn imax(x int, y int) int {
|
||||
return if x > y {
|
||||
x
|
||||
} else {
|
||||
y
|
||||
}
|
||||
return if x > y { x } else { y }
|
||||
}
|
||||
|
||||
fn supports_escape_sequences(fd int) bool {
|
||||
|
Reference in New Issue
Block a user