Commit cdec66ad authored by Kevin Perkins's avatar Kevin Perkins Committed by GitHub

Add option to enable/disable colorful output (#4996)

parent d7c9bd8c
...@@ -20,25 +20,27 @@ DOC = <<DOCOPT ...@@ -20,25 +20,27 @@ DOC = <<DOCOPT
Chromebrew - Package manager for Chrome OS http://skycocker.github.io/chromebrew/ Chromebrew - Package manager for Chrome OS http://skycocker.github.io/chromebrew/
Usage: Usage:
crew build [-k|--keep] [-v|--verbose] <name> ... crew build [options] [-k|--keep] <name> ...
crew const [<name> ...] crew const [options] [<name> ...]
crew download [-v|--verbose] <name> ... crew download [options] <name> ...
crew files <name> ... crew files [options] <name> ...
crew help [<command>] crew help [<command>]
crew install [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] [-v|--verbose] <name> ... crew install [options] [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] <name> ...
crew list (available|installed|compatible|incompatible) crew list [options] (available|installed|compatible|incompatible)
crew postinstall <name> ... crew postinstall [options] <name> ...
crew reinstall [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] [-v|--verbose] <name> ... crew reinstall [options] [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] <name> ...
crew remove [-v|--verbose] <name> ... crew remove [options] <name> ...
crew search [-v|--verbose] [<name> ...] crew search [options] [<name> ...]
crew update crew update [options]
crew upgrade [-k|--keep] [-s|--build-from-source] [-v|--verbose] [<name> ...] crew upgrade [options] [-k|--keep] [-s|--build-from-source] [<name> ...]
crew whatprovides <name> ... crew whatprovides [options] <name> ...
-k --keep Keep the `CREW_BREW_DIR` (#{CREW_BREW_DIR}) directory. -k --keep Keep the `CREW_BREW_DIR` (#{CREW_BREW_DIR}) directory.
-s --build-from-source Build from source even if pre-compiled binary exists. -s --build-from-source Build from source even if pre-compiled binary exists.
-S --recursive-build Build from source, including all dependencies, even if pre-compiled binaries exist. -S --recursive-build Build from source, including all dependencies, even if pre-compiled binaries exist.
-V --version Display the crew version. -V --version Display the crew version.
-c --color Use colors even if standard out is not a tty.
-d --no-color Disable colors even if standard out is a tty.
-v --verbose Show extra information. -v --verbose Show extra information.
-h --help Show this screen. -h --help Show this screen.
...@@ -76,6 +78,7 @@ rescue Docopt::Exit => e ...@@ -76,6 +78,7 @@ rescue Docopt::Exit => e
exit 1 exit 1
end end
String.use_color = args["--color"] || !args["--no-color"]
@opt_keep = args["--keep"] @opt_keep = args["--keep"]
@opt_verbose = args["--verbose"] @opt_verbose = args["--verbose"]
......
# Colorization for strings # Colorization for strings
class String class String
@use_color = STDOUT.isatty
class << self
attr_accessor :use_color
end
def colorize(color_code, shade) def colorize(color_code, shade)
"\e[#{shade};#{color_code}m#{self}\e[0m" if self.class.use_color
return "\e[#{shade};#{color_code}m#{self}\e[0m"
else
return self
end
end end
def black def black
......
# Defines common constants used in different parts of crew # Defines common constants used in different parts of crew
CREW_VERSION = '1.6.0' CREW_VERSION = '1.7.0'
ARCH_ACTUAL = `uname -m`.strip ARCH_ACTUAL = `uname -m`.strip
# This helps with virtualized builds on aarch64 machines # This helps with virtualized builds on aarch64 machines
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment