mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-06 22:24:12 -05:00
* Update package updater to handle llvm and gcc suite packages. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add x86_64 binaries for openmp, libclc. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Add help options. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * Expand help text. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * openmp: Package File Update Run on linux/386 container. * Update gexiv2 anitya mapping. Signed-off-by: Satadru Pramanik <satadru@gmail.com> * openmp: Package File Update Run on linux/amd64 container. --------- Signed-off-by: Satadru Pramanik <satadru@gmail.com> Co-authored-by: Satadru Pramanik <satadru@gmail.com> Co-authored-by: chromebrew-actions[bot] <chromebrew-actions[bot]@users.noreply.github.com> Co-authored-by: satmandu <satmandu@users.noreply.github.com>
67 lines
2.1 KiB
Ruby
67 lines
2.1 KiB
Ruby
# Colorization for strings
|
|
class String
|
|
@@use_color = $stdout.isatty
|
|
|
|
# ANSI color codes
|
|
@@color_codes = {
|
|
black: { normal: 30, background: 40 },
|
|
red: { normal: 31, background: 41 },
|
|
green: { normal: 32, background: 42 },
|
|
orange: { normal: 33, background: 43 },
|
|
blue: { normal: 34, background: 44 },
|
|
purple: { normal: 35, background: 45 },
|
|
cyan: { normal: 36, background: 46 },
|
|
lightgray: { normal: 37, background: 47 },
|
|
lightgrey: { normal: 37, background: 47 },
|
|
|
|
# colors with bold varient available
|
|
gray: { normal: 90, background: 100, bold: 30 },
|
|
grey: { normal: 90, background: 100, bold: 30 },
|
|
lightred: { normal: 91, background: 101, bold: 31 },
|
|
lightgreen: { normal: 92, background: 102, bold: 32 },
|
|
yellow: { normal: 93, background: 103, bold: 33 },
|
|
lightblue: { normal: 94, background: 104, bold: 34 },
|
|
lightpurple: { normal: 95, background: 105, bold: 35 },
|
|
lightcyan: { normal: 96, background: 106, bold: 36 },
|
|
white: { normal: 97, background: 107, bold: 37 }
|
|
}
|
|
|
|
class << self
|
|
# create a getter/setter method for @@use_color
|
|
# like attr_accessor, but attr_accessor works on instance variables only
|
|
def use_color=(use_color)
|
|
@@use_color = use_color
|
|
end
|
|
|
|
def use_color
|
|
return @@use_color
|
|
end
|
|
end
|
|
|
|
def colorize(color_code, shade)
|
|
return @@use_color ? "\e[#{shade};#{color_code}m#{self}\e[0m" : self
|
|
end
|
|
|
|
# create method for each color
|
|
@@color_codes.each_pair do |name, code|
|
|
define_method(name) do |*opts|
|
|
bold_avail = code.key?(:bold)
|
|
|
|
if opts.include?(:background)
|
|
use_bold = false
|
|
color_code = code[:background]
|
|
elsif bold_avail
|
|
# use bold varient by default (if available),
|
|
# specify :no_bold to use normal varient
|
|
use_bold = !opts.include?(:no_bold)
|
|
color_code = code[use_bold ? :bold : :normal]
|
|
else
|
|
use_bold = false
|
|
color_code = code[:normal]
|
|
end
|
|
|
|
return colorize(color_code, use_bold ? 1 : 0)
|
|
end
|
|
end
|
|
end
|