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
Chromebrew - Package manager for Chrome OS http://skycocker.github.io/chromebrew/
Usage:
crew build [-k|--keep] [-v|--verbose] <name> ...
crew const [<name> ...]
crew download [-v|--verbose] <name> ...
crew files <name> ...
crew build [options] [-k|--keep] <name> ...
crew const [options] [<name> ...]
crew download [options] <name> ...
crew files [options] <name> ...
crew help [<command>]
crew install [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] [-v|--verbose] <name> ...
crew list (available|installed|compatible|incompatible)
crew postinstall <name> ...
crew reinstall [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] [-v|--verbose] <name> ...
crew remove [-v|--verbose] <name> ...
crew search [-v|--verbose] [<name> ...]
crew update
crew upgrade [-k|--keep] [-s|--build-from-source] [-v|--verbose] [<name> ...]
crew whatprovides <name> ...
crew install [options] [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] <name> ...
crew list [options] (available|installed|compatible|incompatible)
crew postinstall [options] <name> ...
crew reinstall [options] [-k|--keep] [-s|--build-from-source] [-S|--recursive-build] <name> ...
crew remove [options] <name> ...
crew search [options] [<name> ...]
crew update [options]
crew upgrade [options] [-k|--keep] [-s|--build-from-source] [<name> ...]
crew whatprovides [options] <name> ...
-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 --recursive-build Build from source, including all dependencies, even if pre-compiled binaries exist.
-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.
-h --help Show this screen.
......@@ -76,6 +78,7 @@ rescue Docopt::Exit => e
exit 1
end
String.use_color = args["--color"] || !args["--no-color"]
@opt_keep = args["--keep"]
@opt_verbose = args["--verbose"]
......
# Colorization for strings
class String
@use_color = STDOUT.isatty
class << self
attr_accessor :use_color
end
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
def black
......
# Defines common constants used in different parts of crew
CREW_VERSION = '1.6.0'
CREW_VERSION = '1.7.0'
ARCH_ACTUAL = `uname -m`.strip
# 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