diff --git a/vars/printBanner.groovy b/vars/printBanner.groovy index 30f4565..c2b0f83 100644 --- a/vars/printBanner.groovy +++ b/vars/printBanner.groovy @@ -1,28 +1,45 @@ +void call(String stepName, String boxColor = 'green', String textColor = 'white', String styleName = 'default') { + Map colors = [ + black: '\u001b[30m', + red: '\u001b[31m', + green: '\u001b[32m', + yellow: '\u001b[33m', + blue: '\u001b[34m', + magenta: '\u001b[35m', + cyan: '\u001b[36m', + white: '\u001b[40;37m', + reset: '\u001b[0m', + ] -void call(String stepName) { - red = '\033[31m' - blue = '\033[34m' - normal = '\033[0m' + Map boxStyles = [ + default: [ + tr: '╔', + tl: '╗', + sd: '║', + vr: '═', + br: '╚', + bl: '╜' + ], + plain: [ + tr: '+', + tl: '+', + sd: '|', + vr: '-', + br: '+', + bl: '+' + ] + ] - stepBanner = "║ $blue$stepName$red ║" + Map style = boxStyles[styleName] + + stepBanner = style['sd'] + " ${colors[textColor]}$stepName${colors['reset']}${colors[boxColor]} " + style['sd'] bannerWidth = stepName.length() + 6 - top = '╔' + ('═' * bannerWidth) + '╗' - bottom = '╚' + ('═' * bannerWidth) + '╝' - ansiColor('xterm') { - echo "$red$top\n$stepBanner\n$bottom$normal" + top = style['tr'] + (style['vr'] * bannerWidth) + style['tl'] + bottom = style['br'] + (style['vr'] * bannerWidth) + style['bl'] + ansiColor('css') { + echo "${colors[boxColor]}$top\n$stepBanner\n$bottom${colors['reset']}" } } - // fg_black = '\x1b[30m' - // fg_red = "\x1b[31m" - // fg_green = "\x1b[32m" - // fg_yellow = "\x1b[33m" - // fg_blue = "\x1b[34m" - // fg_magenta = "\x1b[35m" - // fg_cyan = "\x1b[36m" - // fg_white = "\x1b[37m" - // fg_default = "\x1b39m" - // fg_reset = "\x1b[0m" - // ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬