summaryrefslogtreecommitdiffstats
path: root/vendor/colored
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/colored
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/colored')
-rw-r--r--vendor/colored/.cargo-checksum.json1
-rwxr-xr-xvendor/colored/CHANGELOG.md88
-rw-r--r--vendor/colored/Cargo.lock83
-rw-r--r--vendor/colored/Cargo.toml39
-rwxr-xr-xvendor/colored/Dockerfile9
-rwxr-xr-xvendor/colored/LICENSE373
-rwxr-xr-xvendor/colored/README.md184
-rwxr-xr-xvendor/colored/examples/control.rs53
-rwxr-xr-xvendor/colored/examples/dynamic_colors.rs14
-rwxr-xr-xvendor/colored/examples/most_simple.rs24
-rwxr-xr-xvendor/colored/examples/nested_colors.rs16
-rwxr-xr-xvendor/colored/src/color.rs215
-rwxr-xr-xvendor/colored/src/control.rs411
-rwxr-xr-xvendor/colored/src/formatters.rs15
-rwxr-xr-xvendor/colored/src/lib.rs841
-rwxr-xr-xvendor/colored/src/style.rs293
-rwxr-xr-xvendor/colored/tests/ansi_term_compat.rs146
17 files changed, 2805 insertions, 0 deletions
diff --git a/vendor/colored/.cargo-checksum.json b/vendor/colored/.cargo-checksum.json
new file mode 100644
index 000000000..a2730e5b2
--- /dev/null
+++ b/vendor/colored/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"CHANGELOG.md":"08d00cec58e4444b8d58267705aa4b8b8be6cb404dbac396a343ea71857fae96","Cargo.lock":"0a241b71934585d26ec03d6c265b1dbb69971bbfcd4b319a23e28d6cd3581007","Cargo.toml":"fa84955c09e271f41dd86b55a3738f9d3b1fb419dad4fd1b3242e5d3dac75cc1","Dockerfile":"e57d9b655c28d967c6b1b46a1db2e434ea9a4dc55fe1635add74b00265bb3153","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"0807a71aaca98bb5ff5911df7f13305d6a59434b72130c3c54b37b508abc322a","examples/control.rs":"10d95f75d0556c6355d9980007119a11922aff0ebe1809c146e12367bca54955","examples/dynamic_colors.rs":"3bfb4353a665d898be947159e6715d05b911ddab9cfbf650d122c20894935371","examples/most_simple.rs":"9110a7cf8e176dc60653e2a4e4358afdbd72c7ac2dad5cb1fe8fd4b7739211da","examples/nested_colors.rs":"37345018ed494e26ae06c9641039286d967154c795ccaa3ec8dd6b6148f58765","src/color.rs":"4809203b30403689f7befdc4c0371ad732a3d78718ccb0eeb20905034c5feeab","src/control.rs":"8105be4165fa073e65d2851004ecdc5d1b8c69b29f38274ef11b7c83e64cfefe","src/formatters.rs":"77dcc511626c9df54851d9ac2352e80ece7e6e9309f299357ef0e3737c33402d","src/lib.rs":"56a9d56f58464a292316d926265bb1b47c398f5dd82fb02b22a650ef45839dac","src/style.rs":"90ad40942e0f5efe32615c628782e9fa4fa0f98101bad073dda3f687cff2389d","tests/ansi_term_compat.rs":"5658c3d0de456c23ffdca07c92d6a931a7ab3c6ac563417fccb54808cb2d6166"},"package":"b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd"} \ No newline at end of file
diff --git a/vendor/colored/CHANGELOG.md b/vendor/colored/CHANGELOG.md
new file mode 100755
index 000000000..f74427e8f
--- /dev/null
+++ b/vendor/colored/CHANGELOG.md
@@ -0,0 +1,88 @@
+
+# 2.0.0 (July 14, 2020)
+- Add support for true colours.
+- Alter `Color` interface to return `Cow<'static, str>`
+
+# 1.9.3 (February 24, 2020)
+- Fix compilation regression for 1.34.0. Thanks @jlevon for reporting.
+
+# 1.9.2 (January 11, 2020)
+- Exposed `ColoredString` data through methods for purposes of interrogating the applied colours.
+- Increased documentation.
+
+# 1.9.1 (December 31, 2019)
+
+- Remove deprecated `try!` macro in codebase
+- Reduce allocations in `ColoredString` impl (PR#65)
+- Added `"purple"` as match in `impl FromStr for Color` (PR#71)
+
+# 1.9.0 (November 11, 2019)
+
+- **[POSSIBLE_BREAKING CHANGE]:** Replace `winconsole` with `winapi`:
+ - Changes `set_virtual_terminal` function signature.
+- Update dependencies
+- Add Dockerfile
+- Respect tty discovery for CLICOLOR
+
+# 1.8.0 (April 30, 2019)
+
+- FEAT: support Windows 10 colors
+
+# 1.7.0 (January, 2019)
+- TECH: update lazy\_static
+- FEAT: introduce respect for the `NO_COLOR` environment variable
+
+# 1.6.1 (July 9, 2018)
+- TECH: update lazy\_static
+- CHORE: fix typos in README and documentation
+
+# 1.6.0 (October 31, 2017)
+- FEAT: introduced bright colors. `"hello".bright_blue().on_bright_red();`
+- FEAT: introduced strikethrough styling. `"hello".strikethrough();`
+
+# 1.5.3 (September 28, 2017)
+
+- FEAT: derive Copy and Clone for `Color`
+- FEAT: derive Clone for `ColoredString`
+
+# 1.5.2 (July 6, 2017)
+
+- FIX: method `Colorize::reversed` has been added. `Colorize::reverse` was a typo, that we will keep
+ for compatibility
+
+# 1.5.1 (May 9, 2017)
+
+- Update lazy\_static to 0.2.
+
+# 1.5.0 (May 1, 2017)
+
+- FEAT: support for `"hello".color("blue")` (dynamic colors)
+
+# 1.3.2 (Nov 26, 2016)
+
+- FIX: usage of nested ColoredString again, no more style broken mid-line
+
+# 1.3.1 (Oct 14, 2016)
+
+- FIX: usage of ColoredString in a nested way broke the styling mid-line
+
+# 1.3.0 (Jul 31, 2016)
+
+- Provide various options for disabling the coloring in an API-compatible way
+
+# 1.2.0 (Mar 30, 2016)
+
+- Support the different formatting options, like padding and alignment
+
+# 1.1.0 (Mar 15, 2016)
+
+- Respect the CLICOLOR/CLICOLOR\_FORCE behavior. See [this specs](http://bixense.com/clicolors/)
+
+# 1.0.1 (Mar 14, 2016)
+
+- Add a CHANGLOG
+- Fix crate dependencies: move `ansi_term` in dev\_dependencies
+
+# 1.0.0 (Mar 13, 2016)
+
+- Initial release
diff --git a/vendor/colored/Cargo.lock b/vendor/colored/Cargo.lock
new file mode 100644
index 000000000..f80ec9f3a
--- /dev/null
+++ b/vendor/colored/Cargo.lock
@@ -0,0 +1,83 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "atty"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "colored"
+version = "2.0.0"
+dependencies = [
+ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rspec 1.0.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "hermit-abi"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "libc"
+version = "0.2.72"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rspec"
+version = "1.0.0-beta.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[metadata]
+"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
+"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+"checksum libc 0.2.72 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
+"checksum rspec 1.0.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "292964ba6cf097dd3a1fc94c286c8eabf74a0afe709d059d2370e4f1fc766ae2"
+"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
diff --git a/vendor/colored/Cargo.toml b/vendor/colored/Cargo.toml
new file mode 100644
index 000000000..3a6b59be6
--- /dev/null
+++ b/vendor/colored/Cargo.toml
@@ -0,0 +1,39 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "colored"
+version = "2.0.0"
+authors = ["Thomas Wickham <mackwic@gmail.com>"]
+description = "The most simple way to add colors in your terminal"
+homepage = "https://github.com/mackwic/colored"
+readme = "README.md"
+keywords = ["color", "string", "term", "ansi_term", "term-painter"]
+license = "MPL-2.0"
+repository = "https://github.com/mackwic/colored"
+[dependencies.atty]
+version = "0.2"
+
+[dependencies.lazy_static]
+version = "1"
+[dev-dependencies.ansi_term]
+version = "0.12"
+
+[dev-dependencies.rspec]
+version = "=1.0.0-beta.3"
+
+[features]
+no-color = []
+[target."cfg(windows)".dependencies.winapi]
+version = "0.3"
+features = ["consoleapi", "processenv", "winbase"]
+default-features = false
diff --git a/vendor/colored/Dockerfile b/vendor/colored/Dockerfile
new file mode 100755
index 000000000..1bc5ba71b
--- /dev/null
+++ b/vendor/colored/Dockerfile
@@ -0,0 +1,9 @@
+FROM rust:latest
+
+ENV SRC_DIR /src
+RUN mkdir $SRC_DIR
+WORKDIR $SRC_DIR
+VOLUME $SRC_DIR
+
+CMD ["/bin/bash"]
+
diff --git a/vendor/colored/LICENSE b/vendor/colored/LICENSE
new file mode 100755
index 000000000..14e2f777f
--- /dev/null
+++ b/vendor/colored/LICENSE
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/vendor/colored/README.md b/vendor/colored/README.md
new file mode 100755
index 000000000..5d508e793
--- /dev/null
+++ b/vendor/colored/README.md
@@ -0,0 +1,184 @@
+# Colored
+
+[![Build
+Status](https://travis-ci.org/mackwic/colored.svg?branch=master)](https://travis-ci.org/mackwic/colored) [![Crates.io](https://img.shields.io/crates/v/colored.svg?maxAge=2592000)](https://crates.io/crates/colored) [![Crates.io](https://img.shields.io/crates/l/colored.svg?maxAge=2592000)](https://github.com/mackwic/colored/blob/master/LICENSE)
+
+Coloring terminal so simple, you already know how to do it!
+
+```rust
+ "this is blue".blue();
+ "this is red".red();
+ "this is red on blue".red().on_blue();
+ "this is also red on blue".on_blue().red();
+ "you can use truecolor values too!".truecolor(0, 255, 136);
+ "background truecolor also works :)".on_truecolor(135, 28, 167);
+ "bright colors are welcome as well".on_bright_blue().bright_red();
+ "you can also make bold comments".bold();
+ println!("{} {} {}", "or use".cyan(), "any".italic().yellow(), "string type".cyan());
+ "or change advice. This is red".yellow().blue().red();
+ "or clear things up. This is default color and style".red().bold().clear();
+ "purple and magenta are the same".purple().magenta();
+ "and so are normal and clear".normal().clear();
+ "you can specify color by string".color("blue").on_color("red");
+ String::from("this also works!").green().bold();
+ format!("{:30}", "format works as expected. This will be padded".blue());
+ format!("{:.3}", "and this will be green but truncated to 3 chars".green());
+```
+
+## How to use
+
+Add this in your `Cargo.toml`:
+
+```toml
+[dependencies]
+colored = "2"
+```
+
+and add this to your `lib.rs` or `main.rs`:
+
+```rust
+ extern crate colored; // not needed in Rust 2018
+
+ use colored::*;
+
+ // test the example with `cargo run --example most_simple`
+ fn main() {
+ // TADAA!
+ println!("{} {} !", "it".green(), "works".blue().bold());
+ }
+```
+
+## Features
+
+- Safe rust, easy to use, minimal dependencies, complete test suite
+- Respect the `CLICOLOR`/`CLICOLOR_FORCE` behavior (see [the specs](http://bixense.com/clicolors/))
+- Respect the `NO_COLOR` behavior (see [the specs](https://no-color.org/))
+- Works on Linux, MacOS, and Windows (Powershell)
+
+#### Colors:
+
+- black
+- red
+- green
+- yellow
+- blue
+- magenta (or purple)
+- cyan
+- white
+
+Bright colors: prepend the color by `bright_`. So easy.
+Background colors: prepend the color by `on_`. Simple as that.
+Bright Background colors: prepend the color by `on_bright_`. Not hard at all.
+
+#### Truecolors
+
+Colored has support for truecolors where you can specify any arbitrary rgb value.
+
+This feature will only work correctly in terminals which support true colors (i.e. most modern terminals).
+
+You can check if your terminal supports true color by checking the value of the environment variable `$COLORTERM` on your terminal. A value of `truecolor` or `24bit` indicates that it will work.
+
+#### Styles:
+
+- bold
+- underline
+- italic
+- dimmed
+- reversed
+- blink
+- hidden
+- strikethrough
+
+You can clear color _and_ style anytime by using `normal()` or `clear()`
+
+#### Advanced Control:
+
+##### Dynamic color from str
+
+As `Color` implements `FromStr`, `From<&str>`, and `From<String>`, you can easily cast a string into a color like that:
+
+```rust
+// the easy way
+"blue string yo".color("blue");
+
+// this will default to white
+"white string".color("zorglub");
+
+// the safer way via a Result
+let color_res : Result<Color, ()> = "zorglub".parse();
+"red string".color(color_res.unwrap_or(Color::Red));
+```
+
+
+##### Colorization control
+
+If you want to disable any coloring at compile time, you can simply do so by
+using the `no-color` feature.
+
+For example, you can do this in your `Cargo.toml` to disable color in tests:
+
+```toml
+[features]
+# this effectively enable the feature `no-color` of colored when testing with
+# `cargo test --feature dumb_terminal`
+dumb_terminal = ["colored/no-color"]
+```
+
+You can use have even finer control by using the
+`colored::control::set_override` method.
+
+## Build with Docker
+
+### Install Docker
+
+Use the install instructions located [here](https://docs.docker.com/v17.12/install/)
+
+### Build the Docker image
+
+```docker build -t colored_image .```
+
+### Build the library
+
+```docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo build"```
+
+### Test the library
+
+```docker run --rm -it -v "$PWD":/src -u `id -u`:`id -g` colored_image /bin/bash -c "cargo test"```
+
+
+## Todo
+
+- **More tests ?**: We always welcome more tests! Please contribute!
+
+## Credits
+
+This library wouldn't have been the same without the marvelous ruby gem [colored](https://github.com/defunkt/colored).
+
+Thanks for the [ansi\_term crate](https://github.com/ogham/rust-ansi-term) for
+providing a reference implementation, which greatly helped making this crate
+output correct strings.
+
+## License
+
+[Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/2.0/). See the
+[LICENSE](https://github.com/mackwic/colored/blob/master/LICENSE) file at the
+root of the repository.
+
+In non legal terms it means that:
+- if you fix a bug, you MUST give me the code of the fix (it's only fair)
+- if you change/extend the API, you MUST give me the code you changed in the
+ files under MPL2.
+- you CAN'T sue me for anything about this code
+- apart from that, you can do almost whatever you want. See the LICENSE file
+ for details.
+
+## Contributors
+
+- Thomas Wickham: [@mackwic](https://github.com/mackwic)
+- Corey "See More" Richardson: [@cmr](https://github.com/cmr)
+- Iban Eguia: [@Razican](https://github.com/Razican)
+- Alexis "Horgix" Chotard: [@horgix](https://github.com/horgix)
+- Keith Yeung: [@KiChjang](https://github.com/KiChjang)
+- Kyle Galloway: [@kylegalloway](https://github.com/kylegalloway)
+- Luke Hsiao: [@lukehsiao](https://github.com/lukehsiao)
+- kurtlawrence: [@kurtlawrence](https://github.com/kurtlawrence)
diff --git a/vendor/colored/examples/control.rs b/vendor/colored/examples/control.rs
new file mode 100755
index 000000000..b50b42691
--- /dev/null
+++ b/vendor/colored/examples/control.rs
@@ -0,0 +1,53 @@
+extern crate colored;
+use colored::*;
+
+#[cfg(not(windows))]
+fn main() {
+ both()
+}
+
+#[cfg(windows)]
+fn main() {
+ both();
+
+ // additional control setting using windows set_virtual_terminal
+ colored::control::set_virtual_terminal(true);
+ println!("{}", "stdout: Virtual Terminal is in use".bright_green());
+ colored::control::set_virtual_terminal(false);
+ println!(
+ "{}",
+ "stderr: Virtual Terminal is NOT in use, escape chars should be visible".bright_red()
+ );
+ colored::control::set_virtual_terminal(true);
+ println!(
+ "{}",
+ "stdout: Virtual Terminal is in use AGAIN and should be green!".bright_green()
+ );
+ colored::control::set_virtual_terminal(true);
+
+ // again with stderr
+ eprintln!("{}", "stderr: Virtual Terminal is in use".bright_green());
+ colored::control::set_virtual_terminal(false);
+ eprintln!(
+ "{}",
+ "stderr: Virtual Terminal is NOT in use, escape chars should be visible".bright_red()
+ );
+ colored::control::set_virtual_terminal(true);
+ eprintln!(
+ "{}",
+ "stderr: Virtual Terminal is in use AGAIN and should be green!".bright_green()
+ );
+}
+
+fn both() {
+ // this will be yellow if your environment allow it
+ println!("{}", "some warning".yellow());
+ // now , this will be always yellow
+ colored::control::set_override(true);
+ println!("{}", "some warning".yellow());
+ // now, this will be never yellow
+ colored::control::set_override(false);
+ println!("{}", "some warning".yellow());
+ // let the environment decide again
+ colored::control::unset_override();
+}
diff --git a/vendor/colored/examples/dynamic_colors.rs b/vendor/colored/examples/dynamic_colors.rs
new file mode 100755
index 000000000..d9861f425
--- /dev/null
+++ b/vendor/colored/examples/dynamic_colors.rs
@@ -0,0 +1,14 @@
+extern crate colored;
+use colored::*;
+
+fn main() {
+ // the easy way
+ "blue string yo".color("blue");
+
+ // this will default to white
+ "white string".color("zorglub");
+
+ // the safer way via a Result
+ let color_res = "zorglub".parse(); // <- this returns a Result<Color, ()>
+ "red string".color(color_res.unwrap_or(Color::Red));
+}
diff --git a/vendor/colored/examples/most_simple.rs b/vendor/colored/examples/most_simple.rs
new file mode 100755
index 000000000..b94a2b36a
--- /dev/null
+++ b/vendor/colored/examples/most_simple.rs
@@ -0,0 +1,24 @@
+extern crate colored;
+
+use colored::*;
+
+fn main() {
+ // TADAA !
+ println!(
+ "{} {} {}!",
+ "it".green(),
+ "works".blue().bold(),
+ "great".bold().yellow()
+ );
+
+ println!("{}", String::from("this also works!").green().bold());
+
+ let mut s = String::new();
+ s.push_str(&"why not ".red().to_string());
+ s.push_str(&"push things ".blue().to_string());
+ s.push_str(&"a little further ?".green().to_string());
+ println!("{}", s);
+
+ let s = format!("{} {} {}", "this".red(), "is".blue(), "easier".green());
+ println!("{}", s);
+}
diff --git a/vendor/colored/examples/nested_colors.rs b/vendor/colored/examples/nested_colors.rs
new file mode 100755
index 000000000..de1124916
--- /dev/null
+++ b/vendor/colored/examples/nested_colors.rs
@@ -0,0 +1,16 @@
+extern crate colored;
+
+use colored::*;
+
+/*
+ * This example use colored strings in a nested way (at line 14). It shows that colored is able to
+ * keep the correct color on the “!lalalala” part.
+ */
+
+fn main() {
+ let world = "world".bold();
+ let hello_world = format!("Hello, {}!", world);
+ println!("{}", hello_world);
+ let hello_world = format!("Hello, {}!lalalala", world).red();
+ println!("{}", hello_world);
+}
diff --git a/vendor/colored/src/color.rs b/vendor/colored/src/color.rs
new file mode 100755
index 000000000..6e544e8fd
--- /dev/null
+++ b/vendor/colored/src/color.rs
@@ -0,0 +1,215 @@
+use std::{borrow::Cow, str::FromStr};
+
+/// The 8 standard colors.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[allow(missing_docs)]
+pub enum Color {
+ Black,
+ Red,
+ Green,
+ Yellow,
+ Blue,
+ Magenta,
+ Cyan,
+ White,
+ BrightBlack,
+ BrightRed,
+ BrightGreen,
+ BrightYellow,
+ BrightBlue,
+ BrightMagenta,
+ BrightCyan,
+ BrightWhite,
+ TrueColor { r: u8, g: u8, b: u8 },
+}
+
+#[allow(missing_docs)]
+impl Color {
+ pub fn to_fg_str(&self) -> Cow<'static, str> {
+ match *self {
+ Color::Black => "30".into(),
+ Color::Red => "31".into(),
+ Color::Green => "32".into(),
+ Color::Yellow => "33".into(),
+ Color::Blue => "34".into(),
+ Color::Magenta => "35".into(),
+ Color::Cyan => "36".into(),
+ Color::White => "37".into(),
+ Color::BrightBlack => "90".into(),
+ Color::BrightRed => "91".into(),
+ Color::BrightGreen => "92".into(),
+ Color::BrightYellow => "93".into(),
+ Color::BrightBlue => "94".into(),
+ Color::BrightMagenta => "95".into(),
+ Color::BrightCyan => "96".into(),
+ Color::BrightWhite => "97".into(),
+ Color::TrueColor { r, g, b } => format!("38;2;{};{};{}", r, g, b).into(),
+ }
+ }
+
+ pub fn to_bg_str(&self) -> Cow<'static, str> {
+ match *self {
+ Color::Black => "40".into(),
+ Color::Red => "41".into(),
+ Color::Green => "42".into(),
+ Color::Yellow => "43".into(),
+ Color::Blue => "44".into(),
+ Color::Magenta => "45".into(),
+ Color::Cyan => "46".into(),
+ Color::White => "47".into(),
+ Color::BrightBlack => "100".into(),
+ Color::BrightRed => "101".into(),
+ Color::BrightGreen => "102".into(),
+ Color::BrightYellow => "103".into(),
+ Color::BrightBlue => "104".into(),
+ Color::BrightMagenta => "105".into(),
+ Color::BrightCyan => "106".into(),
+ Color::BrightWhite => "107".into(),
+ Color::TrueColor { r, g, b } => format!("48;2;{};{};{}", r, g, b).into(),
+ }
+ }
+}
+
+impl<'a> From<&'a str> for Color {
+ fn from(src: &str) -> Self {
+ src.parse().unwrap_or(Color::White)
+ }
+}
+
+impl From<String> for Color {
+ fn from(src: String) -> Self {
+ src.parse().unwrap_or(Color::White)
+ }
+}
+
+impl FromStr for Color {
+ type Err = ();
+
+ fn from_str(src: &str) -> Result<Self, Self::Err> {
+ let src = src.to_lowercase();
+
+ match src.as_ref() {
+ "black" => Ok(Color::Black),
+ "red" => Ok(Color::Red),
+ "green" => Ok(Color::Green),
+ "yellow" => Ok(Color::Yellow),
+ "blue" => Ok(Color::Blue),
+ "magenta" => Ok(Color::Magenta),
+ "purple" => Ok(Color::Magenta),
+ "cyan" => Ok(Color::Cyan),
+ "white" => Ok(Color::White),
+ "bright black" => Ok(Color::BrightBlack),
+ "bright red" => Ok(Color::BrightRed),
+ "bright green" => Ok(Color::BrightGreen),
+ "bright yellow" => Ok(Color::BrightYellow),
+ "bright blue" => Ok(Color::BrightBlue),
+ "bright magenta" => Ok(Color::BrightMagenta),
+ "bright cyan" => Ok(Color::BrightCyan),
+ "bright white" => Ok(Color::BrightWhite),
+ _ => Err(()),
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ pub use super::*;
+
+ mod from_str {
+ pub use super::*;
+
+ macro_rules! make_test {
+ ( $( $name:ident: $src:expr => $dst:expr),* ) => {
+
+ $(
+ #[test]
+ fn $name() {
+ let color : Color = $src.into();
+ assert_eq!($dst, color)
+ }
+ )*
+ }
+ }
+
+ make_test!(
+ black: "black" => Color::Black,
+ red: "red" => Color::Red,
+ green: "green" => Color::Green,
+ yellow: "yellow" => Color::Yellow,
+ blue: "blue" => Color::Blue,
+ magenta: "magenta" => Color::Magenta,
+ purple: "purple" => Color::Magenta,
+ cyan: "cyan" => Color::Cyan,
+ white: "white" => Color::White,
+ brightblack: "bright black" => Color::BrightBlack,
+ brightred: "bright red" => Color::BrightRed,
+ brightgreen: "bright green" => Color::BrightGreen,
+ brightyellow: "bright yellow" => Color::BrightYellow,
+ brightblue: "bright blue" => Color::BrightBlue,
+ brightmagenta: "bright magenta" => Color::BrightMagenta,
+ brightcyan: "bright cyan" => Color::BrightCyan,
+ brightwhite: "bright white" => Color::BrightWhite,
+
+ invalid: "invalid" => Color::White,
+ capitalized: "BLUE" => Color::Blue,
+ mixed_case: "bLuE" => Color::Blue
+ );
+ }
+
+ mod from_string {
+ pub use super::*;
+
+ macro_rules! make_test {
+ ( $( $name:ident: $src:expr => $dst:expr),* ) => {
+
+ $(
+ #[test]
+ fn $name() {
+ let src = String::from($src);
+ let color : Color = src.into();
+ assert_eq!($dst, color)
+ }
+ )*
+ }
+ }
+
+ make_test!(
+ black: "black" => Color::Black,
+ red: "red" => Color::Red,
+ green: "green" => Color::Green,
+ yellow: "yellow" => Color::Yellow,
+ blue: "blue" => Color::Blue,
+ magenta: "magenta" => Color::Magenta,
+ cyan: "cyan" => Color::Cyan,
+ white: "white" => Color::White,
+ brightblack: "bright black" => Color::BrightBlack,
+ brightred: "bright red" => Color::BrightRed,
+ brightgreen: "bright green" => Color::BrightGreen,
+ brightyellow: "bright yellow" => Color::BrightYellow,
+ brightblue: "bright blue" => Color::BrightBlue,
+ brightmagenta: "bright magenta" => Color::BrightMagenta,
+ brightcyan: "bright cyan" => Color::BrightCyan,
+ brightwhite: "bright white" => Color::BrightWhite,
+
+ invalid: "invalid" => Color::White,
+ capitalized: "BLUE" => Color::Blue,
+ mixed_case: "bLuE" => Color::Blue
+ );
+ }
+
+ mod fromstr {
+ pub use super::*;
+
+ #[test]
+ fn parse() {
+ let color: Result<Color, _> = "blue".parse();
+ assert_eq!(Ok(Color::Blue), color)
+ }
+
+ #[test]
+ fn error() {
+ let color: Result<Color, ()> = "bloublou".parse();
+ assert_eq!(Err(()), color)
+ }
+ }
+}
diff --git a/vendor/colored/src/control.rs b/vendor/colored/src/control.rs
new file mode 100755
index 000000000..7ad6e621e
--- /dev/null
+++ b/vendor/colored/src/control.rs
@@ -0,0 +1,411 @@
+//! A couple of functions to enable and disable coloring.
+
+use std::default::Default;
+use std::env;
+use std::sync::atomic::{AtomicBool, Ordering};
+
+/// Sets a flag to the console to use a virtual terminal environment.
+///
+/// This is primarily used for Windows 10 environments which will not correctly colorize
+/// the outputs based on ANSI escape codes.
+///
+/// The returned `Result` is _always_ `Ok(())`, the return type was kept to ensure backwards
+/// compatibility.
+///
+/// # Notes
+/// > Only available to `Windows` build targets.
+///
+/// # Example
+/// ```rust
+/// use colored::*;
+/// control::set_virtual_terminal(false).unwrap();
+/// println!("{}", "bright cyan".bright_cyan()); // will print 'bright cyan' on windows 10
+///
+/// control::set_virtual_terminal(true).unwrap();
+/// println!("{}", "bright cyan".bright_cyan()); // will print correctly
+/// ```
+#[cfg(windows)]
+pub fn set_virtual_terminal(use_virtual: bool) -> Result<(), ()> {
+ use winapi::{
+ shared::minwindef::DWORD,
+ um::{
+ consoleapi::{GetConsoleMode, SetConsoleMode},
+ processenv::GetStdHandle,
+ winbase::STD_OUTPUT_HANDLE,
+ wincon::ENABLE_VIRTUAL_TERMINAL_PROCESSING,
+ },
+ };
+
+ unsafe {
+ let handle = GetStdHandle(STD_OUTPUT_HANDLE);
+ let mut original_mode: DWORD = 0;
+ GetConsoleMode(handle, &mut original_mode);
+
+ let enabled = original_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING
+ == ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+
+ match (use_virtual, enabled) {
+ // not enabled, should be enabled
+ (true, false) => {
+ SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING | original_mode)
+ }
+ // already enabled, should be disabled
+ (false, true) => {
+ SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING ^ original_mode)
+ }
+ _ => 0,
+ };
+ }
+
+ Ok(())
+}
+
+/// A flag to to if coloring should occur.
+pub struct ShouldColorize {
+ clicolor: bool,
+ clicolor_force: Option<bool>,
+ // XXX we can't use Option<Atomic> because we can't use &mut references to ShouldColorize
+ has_manual_override: AtomicBool,
+ manual_override: AtomicBool,
+}
+
+/// Use this to force colored to ignore the environment and always/never colorize
+/// See example/control.rs
+pub fn set_override(override_colorize: bool) {
+ SHOULD_COLORIZE.set_override(override_colorize)
+}
+
+/// Remove the manual override and let the environment decide if it's ok to colorize
+/// See example/control.rs
+pub fn unset_override() {
+ SHOULD_COLORIZE.unset_override()
+}
+
+lazy_static! {
+/// The persistent [`ShouldColorize`].
+ pub static ref SHOULD_COLORIZE: ShouldColorize = ShouldColorize::from_env();
+}
+
+impl Default for ShouldColorize {
+ fn default() -> ShouldColorize {
+ ShouldColorize {
+ clicolor: true,
+ clicolor_force: None,
+ has_manual_override: AtomicBool::new(false),
+ manual_override: AtomicBool::new(false),
+ }
+ }
+}
+
+impl ShouldColorize {
+ /// Reads environment variables and checks if output is a tty to determine
+ /// whether colorization should be used or not.
+ /// `CLICOLOR_FORCE` takes highest priority, followed by `NO_COLOR`,
+ /// followed by `CLICOLOR` combined with tty check.
+ pub fn from_env() -> Self {
+ ShouldColorize {
+ clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or_else(|| true)
+ && atty::is(atty::Stream::Stdout),
+ clicolor_force: ShouldColorize::resolve_clicolor_force(
+ env::var("NO_COLOR"),
+ env::var("CLICOLOR_FORCE"),
+ ),
+ ..ShouldColorize::default()
+ }
+ }
+
+ /// Returns if the current coloring is expected.
+ pub fn should_colorize(&self) -> bool {
+ if self.has_manual_override.load(Ordering::Relaxed) {
+ return self.manual_override.load(Ordering::Relaxed);
+ }
+
+ if let Some(forced_value) = self.clicolor_force {
+ return forced_value;
+ }
+
+ self.clicolor
+ }
+
+ /// Use this to force colored to ignore the environment and always/never colorize
+ pub fn set_override(&self, override_colorize: bool) {
+ self.has_manual_override.store(true, Ordering::Relaxed);
+ self.manual_override
+ .store(override_colorize, Ordering::Relaxed);
+ }
+
+ /// Remove the manual override and let the environment decide if it's ok to colorize
+ pub fn unset_override(&self) {
+ self.has_manual_override.store(false, Ordering::Relaxed);
+ }
+
+ /* private */
+
+ fn normalize_env(env_res: Result<String, env::VarError>) -> Option<bool> {
+ match env_res {
+ Ok(string) => Some(string != "0"),
+ Err(_) => None,
+ }
+ }
+
+ fn resolve_clicolor_force(
+ no_color: Result<String, env::VarError>,
+ clicolor_force: Result<String, env::VarError>,
+ ) -> Option<bool> {
+ if ShouldColorize::normalize_env(clicolor_force) == Some(true) {
+ Some(true)
+ } else if ShouldColorize::normalize_env(no_color).is_some() {
+ Some(false)
+ } else {
+ None
+ }
+ }
+}
+
+#[cfg(test)]
+mod specs {
+ use super::*;
+ use rspec;
+ use rspec::context::*;
+ use std::env;
+
+ #[test]
+ fn clicolor_behavior() {
+ use std::io;
+
+ let stdout = &mut io::stdout();
+ let mut formatter = rspec::formatter::Simple::new(stdout);
+ let mut runner = describe("ShouldColorize", |ctx| {
+ ctx.describe("::normalize_env", |ctx| {
+ ctx.it("should return None if error", || {
+ assert_eq!(
+ None,
+ ShouldColorize::normalize_env(Err(env::VarError::NotPresent))
+ );
+ assert_eq!(
+ None,
+ ShouldColorize::normalize_env(Err(env::VarError::NotUnicode("".into())))
+ )
+ });
+
+ ctx.it("should return Some(true) if != 0", || {
+ Some(true) == ShouldColorize::normalize_env(Ok(String::from("1")))
+ });
+
+ ctx.it("should return Some(false) if == 0", || {
+ Some(false) == ShouldColorize::normalize_env(Ok(String::from("0")))
+ });
+ });
+
+ ctx.describe("::resolve_clicolor_force", |ctx| {
+ ctx.it(
+ "should return None if NO_COLOR is not set and CLICOLOR_FORCE is not set or set to 0",
+ || {
+ assert_eq!(
+ None,
+ ShouldColorize::resolve_clicolor_force(
+ Err(env::VarError::NotPresent),
+ Err(env::VarError::NotPresent)
+ )
+ );
+ assert_eq!(
+ None,
+ ShouldColorize::resolve_clicolor_force(
+ Err(env::VarError::NotPresent),
+ Ok(String::from("0")),
+ )
+ );
+ },
+ );
+
+ ctx.it(
+ "should return Some(false) if NO_COLOR is set and CLICOLOR_FORCE is not enabled",
+ || {
+ assert_eq!(
+ Some(false),
+ ShouldColorize::resolve_clicolor_force(
+ Ok(String::from("0")),
+ Err(env::VarError::NotPresent)
+ )
+ );
+ assert_eq!(
+ Some(false),
+ ShouldColorize::resolve_clicolor_force(
+ Ok(String::from("1")),
+ Err(env::VarError::NotPresent)
+ )
+ );
+ assert_eq!(
+ Some(false),
+ ShouldColorize::resolve_clicolor_force(
+ Ok(String::from("1")),
+ Ok(String::from("0")),
+ )
+ );
+ },
+ );
+
+ ctx.it(
+ "should prioritize CLICOLOR_FORCE over NO_COLOR if CLICOLOR_FORCE is set to non-zero value",
+ || {
+ assert_eq!(
+ Some(true),
+ ShouldColorize::resolve_clicolor_force(
+ Ok(String::from("1")),
+ Ok(String::from("1")),
+ )
+ );
+ assert_eq!(
+ Some(false),
+ ShouldColorize::resolve_clicolor_force(
+ Ok(String::from("1")),
+ Ok(String::from("0")),
+ )
+ );
+ assert_eq!(
+ Some(true),
+ ShouldColorize::resolve_clicolor_force(
+ Err(env::VarError::NotPresent),
+ Ok(String::from("1")),
+ )
+ );
+ },
+ );
+ });
+
+ ctx.describe("constructors", |ctx| {
+ ctx.it("should have a default constructor", || {
+ ShouldColorize::default();
+ });
+
+ ctx.it("should have an environment constructor", || {
+ ShouldColorize::from_env();
+ });
+ });
+
+ ctx.describe("when only changing clicolors", |ctx| {
+ ctx.it("clicolor == false means no colors", || {
+ let colorize_control = ShouldColorize {
+ clicolor: false,
+ ..ShouldColorize::default()
+ };
+ false == colorize_control.should_colorize()
+ });
+
+ ctx.it("clicolor == true means colors !", || {
+ let colorize_control = ShouldColorize {
+ clicolor: true,
+ ..ShouldColorize::default()
+ };
+ true == colorize_control.should_colorize()
+ });
+
+ ctx.it("unset clicolors implies true", || {
+ true == ShouldColorize::default().should_colorize()
+ });
+ });
+
+ ctx.describe("when using clicolor_force", |ctx| {
+ ctx.it(
+ "clicolor_force should force to true no matter clicolor",
+ || {
+ let colorize_control = ShouldColorize {
+ clicolor: false,
+ clicolor_force: Some(true),
+ ..ShouldColorize::default()
+ };
+
+ true == colorize_control.should_colorize()
+ },
+ );
+
+ ctx.it(
+ "clicolor_force should force to false no matter clicolor",
+ || {
+ let colorize_control = ShouldColorize {
+ clicolor: true,
+ clicolor_force: Some(false),
+ ..ShouldColorize::default()
+ };
+
+ false == colorize_control.should_colorize()
+ },
+ );
+ });
+
+ ctx.describe("using a manual override", |ctx| {
+ ctx.it("shoud colorize if manual_override is true, but clicolor is false and clicolor_force also false", || {
+ let colorize_control = ShouldColorize {
+ clicolor: false,
+ clicolor_force: None,
+ has_manual_override: AtomicBool::new(true),
+ manual_override: AtomicBool::new(true),
+ .. ShouldColorize::default()
+ };
+
+ true == colorize_control.should_colorize()
+ });
+
+ ctx.it("should not colorize if manual_override is false, but clicolor is true or clicolor_force is true", || {
+ let colorize_control = ShouldColorize {
+ clicolor: true,
+ clicolor_force: Some(true),
+ has_manual_override: AtomicBool::new(true),
+ manual_override: AtomicBool::new(false),
+ .. ShouldColorize::default()
+ };
+
+ false == colorize_control.should_colorize()
+ })
+ });
+
+ ctx.describe("::set_override", |ctx| {
+ ctx.it("should exists", || {
+ let colorize_control = ShouldColorize::default();
+ colorize_control.set_override(true);
+ });
+
+ ctx.it("set the manual_override property", || {
+ let colorize_control = ShouldColorize::default();
+ colorize_control.set_override(true);
+ {
+ assert_eq!(
+ true,
+ colorize_control.has_manual_override.load(Ordering::Relaxed)
+ );
+ let val = colorize_control.manual_override.load(Ordering::Relaxed);
+ assert_eq!(true, val);
+ }
+ colorize_control.set_override(false);
+ {
+ assert_eq!(
+ true,
+ colorize_control.has_manual_override.load(Ordering::Relaxed)
+ );
+ let val = colorize_control.manual_override.load(Ordering::Relaxed);
+ assert_eq!(false, val);
+ }
+ });
+ });
+
+ ctx.describe("::unset_override", |ctx| {
+ ctx.it("should exists", || {
+ let colorize_control = ShouldColorize::default();
+ colorize_control.unset_override();
+ });
+
+ ctx.it("unset the manual_override property", || {
+ let colorize_control = ShouldColorize::default();
+ colorize_control.set_override(true);
+ colorize_control.unset_override();
+ assert_eq!(
+ false,
+ colorize_control.has_manual_override.load(Ordering::Relaxed)
+ );
+ });
+ });
+ });
+ runner.add_event_handler(&mut formatter);
+ runner.run().unwrap();
+ }
+}
diff --git a/vendor/colored/src/formatters.rs b/vendor/colored/src/formatters.rs
new file mode 100755
index 000000000..56d5db0d8
--- /dev/null
+++ b/vendor/colored/src/formatters.rs
@@ -0,0 +1,15 @@
+
+use color::Color;
+use style::Style;
+
+pub trait ColoringFormatter {
+ fn format(out: String, fg: Color, bg: Color, style: Style) -> String;
+}
+
+pub struct NoColor;
+
+impl ColoringFormatter for NoColor {
+ fn format(out: String, _fg: Color, _bg: Color, _style: Style) -> String {
+ out
+ }
+}
diff --git a/vendor/colored/src/lib.rs b/vendor/colored/src/lib.rs
new file mode 100755
index 000000000..4475320fc
--- /dev/null
+++ b/vendor/colored/src/lib.rs
@@ -0,0 +1,841 @@
+//!Coloring terminal so simple, you already know how to do it !
+//!
+//! use colored::Colorize;
+//!
+//! "this is blue".blue();
+//! "this is red".red();
+//! "this is red on blue".red().on_blue();
+//! "this is also red on blue".on_blue().red();
+//! "you can use truecolor values too!".truecolor(0, 255, 136);
+//! "background truecolor also works :)".on_truecolor(135, 28, 167);
+//! "you can also make bold comments".bold();
+//! println!("{} {} {}", "or use".cyan(), "any".italic().yellow(), "string type".cyan());
+//! "or change advice. This is red".yellow().blue().red();
+//! "or clear things up. This is default color and style".red().bold().clear();
+//! "purple and magenta are the same".purple().magenta();
+//! "bright colors are also allowed".bright_blue().on_bright_white();
+//! "you can specify color by string".color("blue").on_color("red");
+//! "and so are normal and clear".normal().clear();
+//! String::from("this also works!").green().bold();
+//! format!("{:30}", "format works as expected. This will be padded".blue());
+//! format!("{:.3}", "and this will be green but truncated to 3 chars".green());
+//!
+//!
+//! See [the `Colorize` trait](./trait.Colorize.html) for all the methods.
+//!
+#![warn(missing_docs)]
+
+extern crate atty;
+#[macro_use]
+extern crate lazy_static;
+#[cfg(windows)]
+extern crate winapi;
+
+#[cfg(test)]
+extern crate rspec;
+
+mod color;
+pub mod control;
+mod style;
+
+pub use color::*;
+
+use std::{borrow::Cow, fmt, ops::Deref};
+
+pub use style::{Style, Styles};
+
+/// A string that may have color and/or style applied to it.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct ColoredString {
+ input: String,
+ fgcolor: Option<Color>,
+ bgcolor: Option<Color>,
+ style: style::Style,
+}
+
+/// The trait that enables something to be given color.
+///
+/// You can use `colored` effectively simply by importing this trait
+/// and then using its methods on `String` and `&str`.
+#[allow(missing_docs)]
+pub trait Colorize {
+ // Font Colors
+ fn black(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Black)
+ }
+ fn red(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Red)
+ }
+ fn green(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Green)
+ }
+ fn yellow(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Yellow)
+ }
+ fn blue(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Blue)
+ }
+ fn magenta(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Magenta)
+ }
+ fn purple(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Magenta)
+ }
+ fn cyan(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::Cyan)
+ }
+ fn white(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::White)
+ }
+ fn bright_black(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightBlack)
+ }
+ fn bright_red(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightRed)
+ }
+ fn bright_green(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightGreen)
+ }
+ fn bright_yellow(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightYellow)
+ }
+ fn bright_blue(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightBlue)
+ }
+ fn bright_magenta(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightMagenta)
+ }
+ fn bright_purple(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightMagenta)
+ }
+ fn bright_cyan(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightCyan)
+ }
+ fn bright_white(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::BrightWhite)
+ }
+ fn truecolor(self, r: u8, g: u8, b: u8) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.color(Color::TrueColor { r, g, b })
+ }
+ fn color<S: Into<Color>>(self, color: S) -> ColoredString;
+ // Background Colors
+ fn on_black(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Black)
+ }
+ fn on_red(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Red)
+ }
+ fn on_green(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Green)
+ }
+ fn on_yellow(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Yellow)
+ }
+ fn on_blue(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Blue)
+ }
+ fn on_magenta(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Magenta)
+ }
+ fn on_purple(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Magenta)
+ }
+ fn on_cyan(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::Cyan)
+ }
+ fn on_white(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::White)
+ }
+ fn on_bright_black(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightBlack)
+ }
+ fn on_bright_red(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightRed)
+ }
+ fn on_bright_green(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightGreen)
+ }
+ fn on_bright_yellow(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightYellow)
+ }
+ fn on_bright_blue(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightBlue)
+ }
+ fn on_bright_magenta(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightMagenta)
+ }
+ fn on_bright_purple(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightMagenta)
+ }
+ fn on_bright_cyan(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightCyan)
+ }
+ fn on_bright_white(self) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::BrightWhite)
+ }
+ fn on_truecolor(self, r: u8, g: u8, b: u8) -> ColoredString
+ where
+ Self: Sized,
+ {
+ self.on_color(Color::TrueColor { r, g, b })
+ }
+ fn on_color<S: Into<Color>>(self, color: S) -> ColoredString;
+ // Styles
+ fn clear(self) -> ColoredString;
+ fn normal(self) -> ColoredString;
+ fn bold(self) -> ColoredString;
+ fn dimmed(self) -> ColoredString;
+ fn italic(self) -> ColoredString;
+ fn underline(self) -> ColoredString;
+ fn blink(self) -> ColoredString;
+ /// Historical name of `Colorize::reversed`. May be removed in a future version. Please use
+ /// `Colorize::reversed` instead
+ fn reverse(self) -> ColoredString;
+ /// This should be preferred to `Colorize::reverse`.
+ fn reversed(self) -> ColoredString;
+ fn hidden(self) -> ColoredString;
+ fn strikethrough(self) -> ColoredString;
+}
+
+impl ColoredString {
+ /// Get the current background color applied.
+ ///
+ /// ```rust
+ /// # use colored::*;
+ /// let cstr = "".blue();
+ /// assert_eq!(cstr.fgcolor(), Some(Color::Blue));
+ /// let cstr = cstr.clear();
+ /// assert_eq!(cstr.fgcolor(), None);
+ /// ```
+ pub fn fgcolor(&self) -> Option<Color> {
+ self.fgcolor.as_ref().copied()
+ }
+
+ /// Get the current background color applied.
+ ///
+ /// ```rust
+ /// # use colored::*;
+ /// let cstr = "".on_blue();
+ /// assert_eq!(cstr.bgcolor(), Some(Color::Blue));
+ /// let cstr = cstr.clear();
+ /// assert_eq!(cstr.bgcolor(), None);
+ /// ```
+ pub fn bgcolor(&self) -> Option<Color> {
+ self.bgcolor.as_ref().copied()
+ }
+
+ /// Get the current [`Style`] which can be check if it contains a [`Styles`].
+ ///
+ /// ```rust
+ /// # use colored::*;
+ /// let colored = "".bold().italic();
+ /// assert_eq!(colored.style().contains(Styles::Bold), true);
+ /// assert_eq!(colored.style().contains(Styles::Italic), true);
+ /// assert_eq!(colored.style().contains(Styles::Dimmed), false);
+ /// ```
+ pub fn style(&self) -> style::Style {
+ self.style
+ }
+
+ /// Checks if the colored string has no color or styling.
+ ///
+ /// ```rust
+ /// # use colored::*;
+ /// let cstr = "".red();
+ /// assert_eq!(cstr.is_plain(), false);
+ /// let cstr = cstr.clear();
+ /// assert_eq!(cstr.is_plain(), true);
+ /// ```
+ pub fn is_plain(&self) -> bool {
+ self.bgcolor.is_none() && self.fgcolor.is_none() && self.style == style::CLEAR
+ }
+
+ #[cfg(not(feature = "no-color"))]
+ fn has_colors(&self) -> bool {
+ control::SHOULD_COLORIZE.should_colorize()
+ }
+
+ #[cfg(feature = "no-color")]
+ fn has_colors(&self) -> bool {
+ false
+ }
+
+ fn compute_style(&self) -> String {
+ if !self.has_colors() || self.is_plain() {
+ return String::new();
+ }
+
+ let mut res = String::from("\x1B[");
+ let mut has_wrote = if self.style != style::CLEAR {
+ res.push_str(&self.style.to_str());
+ true
+ } else {
+ false
+ };
+
+ if let Some(ref bgcolor) = self.bgcolor {
+ if has_wrote {
+ res.push(';');
+ }
+
+ res.push_str(&bgcolor.to_bg_str());
+ has_wrote = true;
+ }
+
+ if let Some(ref fgcolor) = self.fgcolor {
+ if has_wrote {
+ res.push(';');
+ }
+
+ res.push_str(&fgcolor.to_fg_str());
+ }
+
+ res.push('m');
+ res
+ }
+
+ fn escape_inner_reset_sequences(&self) -> Cow<str> {
+ if !self.has_colors() || self.is_plain() {
+ return self.input.as_str().into();
+ }
+
+ // TODO: BoyScoutRule
+ let reset = "\x1B[0m";
+ let style = self.compute_style();
+ let matches: Vec<usize> = self
+ .input
+ .match_indices(reset)
+ .map(|(idx, _)| idx)
+ .collect();
+ if matches.is_empty() {
+ return self.input.as_str().into();
+ }
+
+ let mut input = self.input.clone();
+ input.reserve(matches.len() * style.len());
+
+ for (idx_in_matches, offset) in matches.into_iter().enumerate() {
+ // shift the offset to the end of the reset sequence and take in account
+ // the number of matches we have escaped (which shift the index to insert)
+ let mut offset = offset + reset.len() + idx_in_matches * style.len();
+
+ for cchar in style.chars() {
+ input.insert(offset, cchar);
+ offset += 1;
+ }
+ }
+
+ input.into()
+ }
+}
+
+impl Default for ColoredString {
+ fn default() -> Self {
+ ColoredString {
+ input: String::default(),
+ fgcolor: None,
+ bgcolor: None,
+ style: style::CLEAR,
+ }
+ }
+}
+
+impl Deref for ColoredString {
+ type Target = str;
+ fn deref(&self) -> &str {
+ &self.input
+ }
+}
+
+impl<'a> From<&'a str> for ColoredString {
+ fn from(s: &'a str) -> Self {
+ ColoredString {
+ input: String::from(s),
+ ..ColoredString::default()
+ }
+ }
+}
+
+impl Colorize for ColoredString {
+ fn color<S: Into<Color>>(mut self, color: S) -> ColoredString {
+ self.fgcolor = Some(color.into());
+ self
+ }
+ fn on_color<S: Into<Color>>(mut self, color: S) -> ColoredString {
+ self.bgcolor = Some(color.into());
+ self
+ }
+
+ fn clear(self) -> ColoredString {
+ ColoredString {
+ input: self.input,
+ ..ColoredString::default()
+ }
+ }
+ fn normal(self) -> ColoredString {
+ self.clear()
+ }
+ fn bold(mut self) -> ColoredString {
+ self.style.add(style::Styles::Bold);
+ self
+ }
+ fn dimmed(mut self) -> ColoredString {
+ self.style.add(style::Styles::Dimmed);
+ self
+ }
+ fn italic(mut self) -> ColoredString {
+ self.style.add(style::Styles::Italic);
+ self
+ }
+ fn underline(mut self) -> ColoredString {
+ self.style.add(style::Styles::Underline);
+ self
+ }
+ fn blink(mut self) -> ColoredString {
+ self.style.add(style::Styles::Blink);
+ self
+ }
+ fn reverse(self) -> ColoredString {
+ self.reversed()
+ }
+ fn reversed(mut self) -> ColoredString {
+ self.style.add(style::Styles::Reversed);
+ self
+ }
+ fn hidden(mut self) -> ColoredString {
+ self.style.add(style::Styles::Hidden);
+ self
+ }
+ fn strikethrough(mut self) -> ColoredString {
+ self.style.add(style::Styles::Strikethrough);
+ self
+ }
+}
+
+impl<'a> Colorize for &'a str {
+ fn color<S: Into<Color>>(self, color: S) -> ColoredString {
+ ColoredString {
+ fgcolor: Some(color.into()),
+ input: String::from(self),
+ ..ColoredString::default()
+ }
+ }
+
+ fn on_color<S: Into<Color>>(self, color: S) -> ColoredString {
+ ColoredString {
+ bgcolor: Some(color.into()),
+ input: String::from(self),
+ ..ColoredString::default()
+ }
+ }
+
+ fn clear(self) -> ColoredString {
+ ColoredString {
+ input: String::from(self),
+ style: style::CLEAR,
+ ..ColoredString::default()
+ }
+ }
+ fn normal(self) -> ColoredString {
+ self.clear()
+ }
+ fn bold(self) -> ColoredString {
+ ColoredString::from(self).bold()
+ }
+ fn dimmed(self) -> ColoredString {
+ ColoredString::from(self).dimmed()
+ }
+ fn italic(self) -> ColoredString {
+ ColoredString::from(self).italic()
+ }
+ fn underline(self) -> ColoredString {
+ ColoredString::from(self).underline()
+ }
+ fn blink(self) -> ColoredString {
+ ColoredString::from(self).blink()
+ }
+ fn reverse(self) -> ColoredString {
+ self.reversed()
+ }
+ fn reversed(self) -> ColoredString {
+ ColoredString::from(self).reversed()
+ }
+ fn hidden(self) -> ColoredString {
+ ColoredString::from(self).hidden()
+ }
+ fn strikethrough(self) -> ColoredString {
+ ColoredString::from(self).strikethrough()
+ }
+}
+
+impl fmt::Display for ColoredString {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ if !self.has_colors() || self.is_plain() {
+ return <String as fmt::Display>::fmt(&self.input, f);
+ }
+
+ // XXX: see tests. Useful when nesting colored strings
+ let escaped_input = self.escape_inner_reset_sequences();
+
+ f.write_str(&self.compute_style())?;
+ escaped_input.fmt(f)?;
+ f.write_str("\x1B[0m")?;
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn formatting() {
+ // respect the formatting. Escape sequence add some padding so >= 40
+ assert!(format!("{:40}", "".blue()).len() >= 40);
+ // both should be truncated to 1 char before coloring
+ assert_eq!(
+ format!("{:1.1}", "toto".blue()).len(),
+ format!("{:1.1}", "1".blue()).len()
+ )
+ }
+
+ #[test]
+ fn it_works() {
+ let toto = "toto";
+ println!("{}", toto.red());
+ println!("{}", String::from(toto).red());
+ println!("{}", toto.blue());
+
+ println!("blue style ****");
+ println!("{}", toto.bold());
+ println!("{}", "yeah ! Red bold !".red().bold());
+ println!("{}", "yeah ! Yellow bold !".bold().yellow());
+ println!("{}", toto.bold().blue());
+ println!("{}", toto.blue().bold());
+ println!("{}", toto.blue().bold().underline());
+ println!("{}", toto.blue().italic());
+ println!("******");
+ println!("test clearing");
+ println!("{}", "red cleared".red().clear());
+ println!("{}", "bold cyan cleared".bold().cyan().clear());
+ println!("******");
+ println!("Bg tests");
+ println!("{}", toto.green().on_blue());
+ println!("{}", toto.on_magenta().yellow());
+ println!("{}", toto.purple().on_yellow());
+ println!("{}", toto.magenta().on_white());
+ println!("{}", toto.cyan().on_green());
+ println!("{}", toto.black().on_white());
+ println!("******");
+ println!("{}", toto.green());
+ println!("{}", toto.yellow());
+ println!("{}", toto.purple());
+ println!("{}", toto.magenta());
+ println!("{}", toto.cyan());
+ println!("{}", toto.white());
+ println!("{}", toto.white().red().blue().green());
+ println!("{}", toto.truecolor(255, 0, 0));
+ println!("{}", toto.truecolor(255, 255, 0));
+ println!("{}", toto.on_truecolor(0, 80, 80));
+ // uncomment to see term output
+ // assert!(false)
+ }
+
+ #[test]
+ fn compute_style_empty_string() {
+ assert_eq!("", "".clear().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_simple_fg_blue() {
+ let blue = "\x1B[34m";
+
+ assert_eq!(blue, "".blue().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_simple_bg_blue() {
+ let on_blue = "\x1B[44m";
+
+ assert_eq!(on_blue, "".on_blue().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_blue_on_blue() {
+ let blue_on_blue = "\x1B[44;34m";
+
+ assert_eq!(blue_on_blue, "".blue().on_blue().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_simple_fg_bright_blue() {
+ let blue = "\x1B[94m";
+
+ assert_eq!(blue, "".bright_blue().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_simple_bg_bright_blue() {
+ let on_blue = "\x1B[104m";
+
+ assert_eq!(on_blue, "".on_bright_blue().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_bright_blue_on_bright_blue() {
+ let blue_on_blue = "\x1B[104;94m";
+
+ assert_eq!(
+ blue_on_blue,
+ "".bright_blue().on_bright_blue().compute_style()
+ );
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_simple_bold() {
+ let bold = "\x1B[1m";
+
+ assert_eq!(bold, "".bold().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_blue_bold() {
+ let blue_bold = "\x1B[1;34m";
+
+ assert_eq!(blue_bold, "".blue().bold().compute_style());
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn compute_style_blue_bold_on_blue() {
+ let blue_bold_on_blue = "\x1B[1;44;34m";
+
+ assert_eq!(
+ blue_bold_on_blue,
+ "".blue().bold().on_blue().compute_style()
+ );
+ }
+
+ #[test]
+ fn escape_reset_sequence_spec_should_do_nothing_on_empty_strings() {
+ let style = ColoredString::default();
+ let expected = String::new();
+
+ let output = style.escape_inner_reset_sequences();
+
+ assert_eq!(expected, output);
+ }
+
+ #[test]
+ fn escape_reset_sequence_spec_should_do_nothing_on_string_with_no_reset() {
+ let style = ColoredString {
+ input: String::from("hello world !"),
+ ..ColoredString::default()
+ };
+
+ let expected = String::from("hello world !");
+ let output = style.escape_inner_reset_sequences();
+
+ assert_eq!(expected, output);
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn escape_reset_sequence_spec_should_replace_inner_reset_sequence_with_current_style() {
+ let input = format!("start {} end", String::from("hello world !").red());
+ let style = input.blue();
+
+ let output = style.escape_inner_reset_sequences();
+ let blue = "\x1B[34m";
+ let red = "\x1B[31m";
+ let reset = "\x1B[0m";
+ let expected = format!("start {}hello world !{}{} end", red, reset, blue);
+ assert_eq!(expected, output);
+ }
+
+ #[cfg_attr(feature = "no-color", ignore)]
+ #[test]
+ fn escape_reset_sequence_spec_should_replace_multiple_inner_reset_sequences_with_current_style()
+ {
+ let italic_str = String::from("yo").italic();
+ let input = format!(
+ "start 1:{} 2:{} 3:{} end",
+ italic_str, italic_str, italic_str
+ );
+ let style = input.blue();
+
+ let output = style.escape_inner_reset_sequences();
+ let blue = "\x1B[34m";
+ let italic = "\x1B[3m";
+ let reset = "\x1B[0m";
+ let expected = format!(
+ "start 1:{}yo{}{} 2:{}yo{}{} 3:{}yo{}{} end",
+ italic, reset, blue, italic, reset, blue, italic, reset, blue
+ );
+
+ println!("first: {}\nsecond: {}", expected, output);
+
+ assert_eq!(expected, output);
+ }
+
+ #[test]
+ fn color_fn() {
+ assert_eq!("blue".blue(), "blue".color("blue"))
+ }
+
+ #[test]
+ fn on_color_fn() {
+ assert_eq!("blue".on_blue(), "blue".on_color("blue"))
+ }
+
+ #[test]
+ fn bright_color_fn() {
+ assert_eq!("blue".bright_blue(), "blue".color("bright blue"))
+ }
+
+ #[test]
+ fn on_bright_color_fn() {
+ assert_eq!("blue".on_bright_blue(), "blue".on_color("bright blue"))
+ }
+
+ #[test]
+ fn exposing_tests() {
+ let cstring = "".red();
+ assert_eq!(cstring.fgcolor(), Some(Color::Red));
+ assert_eq!(cstring.bgcolor(), None);
+
+ let cstring = cstring.clear();
+ assert_eq!(cstring.fgcolor(), None);
+ assert_eq!(cstring.bgcolor(), None);
+
+ let cstring = cstring.blue().on_bright_yellow();
+ assert_eq!(cstring.fgcolor(), Some(Color::Blue));
+ assert_eq!(cstring.bgcolor(), Some(Color::BrightYellow));
+
+ let cstring = cstring.bold().italic();
+ assert_eq!(cstring.fgcolor(), Some(Color::Blue));
+ assert_eq!(cstring.bgcolor(), Some(Color::BrightYellow));
+ assert_eq!(cstring.style().contains(Styles::Bold), true);
+ assert_eq!(cstring.style().contains(Styles::Italic), true);
+ assert_eq!(cstring.style().contains(Styles::Dimmed), false);
+ }
+}
diff --git a/vendor/colored/src/style.rs b/vendor/colored/src/style.rs
new file mode 100755
index 000000000..bf97acc99
--- /dev/null
+++ b/vendor/colored/src/style.rs
@@ -0,0 +1,293 @@
+const CLEARV: u8 = 0b0000_0000;
+const BOLD: u8 = 0b0000_0001;
+const UNDERLINE: u8 = 0b0000_0010;
+const REVERSED: u8 = 0b0000_0100;
+const ITALIC: u8 = 0b0000_1000;
+const BLINK: u8 = 0b0001_0000;
+const HIDDEN: u8 = 0b0010_0000;
+const DIMMED: u8 = 0b0100_0000;
+const STRIKETHROUGH: u8 = 0b1000_0000;
+
+static STYLES: [(u8, Styles); 8] = [
+ (BOLD, Styles::Bold),
+ (DIMMED, Styles::Dimmed),
+ (UNDERLINE, Styles::Underline),
+ (REVERSED, Styles::Reversed),
+ (ITALIC, Styles::Italic),
+ (BLINK, Styles::Blink),
+ (HIDDEN, Styles::Hidden),
+ (STRIKETHROUGH, Styles::Strikethrough),
+];
+
+pub static CLEAR: Style = Style(CLEARV);
+
+/// A combinatorial style such as bold, italics, dimmed, etc.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub struct Style(u8);
+
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+#[allow(missing_docs)]
+pub enum Styles {
+ Clear,
+ Bold,
+ Dimmed,
+ Underline,
+ Reversed,
+ Italic,
+ Blink,
+ Hidden,
+ Strikethrough,
+}
+
+impl Styles {
+ fn to_str<'a>(self) -> &'a str {
+ match self {
+ Styles::Clear => "", // unreachable, but we don't want to panic
+ Styles::Bold => "1",
+ Styles::Dimmed => "2",
+ Styles::Italic => "3",
+ Styles::Underline => "4",
+ Styles::Blink => "5",
+ Styles::Reversed => "7",
+ Styles::Hidden => "8",
+ Styles::Strikethrough => "9",
+ }
+ }
+
+ fn to_u8(self) -> u8 {
+ match self {
+ Styles::Clear => CLEARV,
+ Styles::Bold => BOLD,
+ Styles::Dimmed => DIMMED,
+ Styles::Italic => ITALIC,
+ Styles::Underline => UNDERLINE,
+ Styles::Blink => BLINK,
+ Styles::Reversed => REVERSED,
+ Styles::Hidden => HIDDEN,
+ Styles::Strikethrough => STRIKETHROUGH,
+ }
+ }
+
+ fn from_u8(u: u8) -> Option<Vec<Styles>> {
+ if u == CLEARV {
+ return None;
+ }
+
+ let res: Vec<Styles> = STYLES
+ .iter()
+ .filter(|&&(ref mask, _)| (0 != (u & mask)))
+ .map(|&(_, value)| value)
+ .collect();
+ if res.is_empty() {
+ None
+ } else {
+ Some(res)
+ }
+ }
+}
+
+impl Style {
+ /// Check if the current style has one of [`Styles`](Styles) switched on.
+ ///
+ /// ```rust
+ /// # use colored::*;
+ /// let colored = "".bold().italic();
+ /// assert_eq!(colored.style().contains(Styles::Bold), true);
+ /// assert_eq!(colored.style().contains(Styles::Italic), true);
+ /// assert_eq!(colored.style().contains(Styles::Dimmed), false);
+ /// ```
+ pub fn contains(self, style: Styles) -> bool {
+ let s = style.to_u8();
+ self.0 & s == s
+ }
+
+ pub(crate) fn to_str(self) -> String {
+ let styles = Styles::from_u8(self.0).unwrap_or_default();
+ styles
+ .iter()
+ .map(|s| s.to_str())
+ .collect::<Vec<&str>>()
+ .join(";")
+ }
+
+ pub(crate) fn add(&mut self, two: Styles) {
+ self.0 |= two.to_u8();
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ mod u8_to_styles_invalid_is_none {
+ use super::super::Styles;
+ use super::super::CLEARV;
+
+ #[test]
+ fn empty_is_none() {
+ assert_eq!(None, Styles::from_u8(CLEARV))
+ }
+ }
+
+ mod u8_to_styles_isomorphism {
+ use super::super::Styles;
+ use super::super::{
+ BLINK, BOLD, DIMMED, HIDDEN, ITALIC, REVERSED, STRIKETHROUGH, UNDERLINE,
+ };
+
+ macro_rules! value_isomorph {
+ ($name:ident, $value:expr) => {
+ #[test]
+ fn $name() {
+ let u = Styles::from_u8($value);
+ assert!(
+ u.is_some(),
+ "{}: Styles::from_u8 -> None",
+ stringify!($value)
+ );
+ let u = u.unwrap();
+ assert!(
+ u.len() == 1,
+ "{}: Styles::from_u8 found {} styles (expected 1)",
+ stringify!($value),
+ u.len()
+ );
+ assert!(
+ u[0].to_u8() == $value,
+ "{}: to_u8() doesn't match its const value",
+ stringify!($value)
+ );
+ }
+ };
+ }
+
+ value_isomorph!(bold, BOLD);
+ value_isomorph!(underline, UNDERLINE);
+ value_isomorph!(reversed, REVERSED);
+ value_isomorph!(italic, ITALIC);
+ value_isomorph!(blink, BLINK);
+ value_isomorph!(hidden, HIDDEN);
+ value_isomorph!(dimmed, DIMMED);
+ value_isomorph!(strikethrough, STRIKETHROUGH);
+ }
+
+ mod styles_combine_complex {
+ use super::super::Styles::*;
+ use super::super::{Style, Styles};
+
+ fn style_from_multiples(styles: &[Styles]) -> Style {
+ let mut res = Style(styles[0].to_u8());
+ for s in &styles[1..] {
+ res = Style(res.0 | s.to_u8());
+ }
+ res
+ }
+
+ macro_rules! test_aggreg {
+ ($styles:expr, $expect:expr) => {{
+ let v = style_from_multiples($styles);
+ let r = Styles::from_u8(v.0).expect("should find styles");
+ assert_eq!(&$expect as &[Styles], &r[..])
+ }};
+ }
+
+ #[test]
+ fn aggreg1() {
+ let styles: &[Styles] = &[Bold, Bold, Bold];
+ test_aggreg!(styles, [Bold])
+ }
+
+ #[test]
+ fn aggreg2() {
+ let styles: &[Styles] = &[Italic, Italic, Bold, Bold];
+ test_aggreg!(styles, [Bold, Italic])
+ }
+
+ #[test]
+ fn aggreg3() {
+ let styles: &[Styles] = &[Bold, Italic, Bold];
+ test_aggreg!(styles, [Bold, Italic])
+ }
+
+ macro_rules! test_combine {
+ ($styles:expr) => {{
+ let v = style_from_multiples($styles);
+ let r = Styles::from_u8(v.0).expect("should find styles");
+ assert_eq!($styles, &r[..])
+ }};
+ }
+
+ #[test]
+ fn two1() {
+ let s: &[Styles] = &[Bold, Underline];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn two2() {
+ let s: &[Styles] = &[Underline, Italic];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn two3() {
+ let s: &[Styles] = &[Bold, Italic];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn three1() {
+ let s: &[Styles] = &[Bold, Underline, Italic];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn three2() {
+ let s: &[Styles] = &[Dimmed, Underline, Italic];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn four() {
+ let s: &[Styles] = &[Dimmed, Underline, Italic, Hidden];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn five() {
+ let s: &[Styles] = &[Dimmed, Underline, Italic, Blink, Hidden];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn six() {
+ let s: &[Styles] = &[Bold, Dimmed, Underline, Italic, Blink, Hidden];
+ test_combine!(s)
+ }
+
+ #[test]
+ fn all() {
+ let s: &[Styles] = &[
+ Bold,
+ Dimmed,
+ Underline,
+ Reversed,
+ Italic,
+ Blink,
+ Hidden,
+ Strikethrough,
+ ];
+ test_combine!(s)
+ }
+ }
+
+ #[test]
+ fn test_style_contains() {
+ let mut style = Style(Styles::Bold.to_u8());
+ style.add(Styles::Italic);
+
+ assert_eq!(style.contains(Styles::Bold), true);
+ assert_eq!(style.contains(Styles::Italic), true);
+ assert_eq!(style.contains(Styles::Dimmed), false);
+ }
+}
diff --git a/vendor/colored/tests/ansi_term_compat.rs b/vendor/colored/tests/ansi_term_compat.rs
new file mode 100755
index 000000000..6683ee0c8
--- /dev/null
+++ b/vendor/colored/tests/ansi_term_compat.rs
@@ -0,0 +1,146 @@
+#![cfg(not(feature = "no-color"))]
+#![allow(unused_imports)]
+
+extern crate ansi_term;
+extern crate colored;
+
+use ansi_term::*;
+use colored::*;
+
+macro_rules! test_simple_color {
+ ($string:expr, $colored_name:ident, $ansi_term_name:ident) => {
+ #[test]
+ fn $colored_name() {
+ let s = format!("{} {}", $string, stringify!($colored_name));
+ assert_eq!(
+ s.$colored_name().to_string(),
+ Colour::$ansi_term_name.paint(s).to_string()
+ )
+ }
+ };
+}
+
+mod compat_colors {
+ use super::ansi_term::*;
+ use super::colored::*;
+
+ test_simple_color!("test string", black, Black);
+ test_simple_color!("test string", red, Red);
+ test_simple_color!("test string", green, Green);
+ test_simple_color!("test string", yellow, Yellow);
+ test_simple_color!("test string", blue, Blue);
+ test_simple_color!("test string", magenta, Purple);
+ test_simple_color!("test string", cyan, Cyan);
+ test_simple_color!("test string", white, White);
+}
+
+macro_rules! test_simple_style {
+ ($string:expr, $style:ident) => {
+ #[test]
+ fn $style() {
+ let s = format!("{} {}", $string, stringify!($style));
+ assert_eq!(
+ s.$style().to_string(),
+ ansi_term::Style::new().$style().paint(s).to_string()
+ )
+ }
+ };
+}
+
+mod compat_styles {
+ use super::ansi_term;
+ use super::ansi_term::*;
+ use super::colored;
+ use super::colored::*;
+
+ test_simple_style!("test string", bold);
+ test_simple_style!("test string", dimmed);
+ test_simple_style!("test string", italic);
+ test_simple_style!("test string", underline);
+ test_simple_style!("test string", blink);
+ test_simple_style!("test string", reverse);
+ test_simple_style!("test string", hidden);
+}
+
+macro_rules! test_simple_bgcolor {
+ ($string:expr, $colored_name:ident, $ansi_term_name:ident) => {
+ #[test]
+ fn $colored_name() {
+ let s = format!("{} {}", $string, stringify!($colored_name));
+ assert_eq!(
+ s.$colored_name().to_string(),
+ ansi_term::Style::default()
+ .on(ansi_term::Colour::$ansi_term_name)
+ .paint(s)
+ .to_string()
+ )
+ }
+ };
+}
+
+mod compat_bgcolors {
+ use super::ansi_term;
+ use super::ansi_term::*;
+ use super::colored;
+ use super::colored::*;
+
+ test_simple_bgcolor!("test string", on_black, Black);
+ test_simple_bgcolor!("test string", on_red, Red);
+ test_simple_bgcolor!("test string", on_green, Green);
+ test_simple_bgcolor!("test string", on_yellow, Yellow);
+ test_simple_bgcolor!("test string", on_blue, Blue);
+ test_simple_bgcolor!("test string", on_magenta, Purple);
+ test_simple_bgcolor!("test string", on_cyan, Cyan);
+ test_simple_bgcolor!("test string", on_white, White);
+}
+
+mod compat_complex {
+ use super::ansi_term;
+ use super::ansi_term::*;
+ use super::colored;
+ use super::colored::*;
+
+ #[test]
+ fn complex1() {
+ let s = "test string";
+ let ansi = Colour::Red.on(Colour::Black).bold().italic().paint(s);
+ assert_eq!(
+ ansi.to_string(),
+ s.red().bold().italic().on_black().to_string()
+ );
+ }
+
+ #[test]
+ fn complex2() {
+ let s = "test string";
+ let ansi = Colour::Green.on(Colour::Yellow).underline().paint(s);
+ assert_eq!(
+ ansi.to_string(),
+ s.green().on_yellow().underline().to_string()
+ );
+ }
+}
+
+mod compat_overrides {
+ use super::ansi_term;
+ use super::ansi_term::*;
+ use super::colored;
+ use super::colored::*;
+
+ #[test]
+ fn overrides1() {
+ let s = "test string";
+ let ansi = Colour::Red.on(Colour::Black).on(Colour::Blue).paint(s);
+ assert_eq!(ansi.to_string(), s.red().on_blue().to_string());
+ }
+
+ #[test]
+ fn overrides2() {
+ let s = "test string";
+ let ansi = Colour::Green.on(Colour::Yellow).paint(s);
+ assert_eq!(
+ ansi.to_string(),
+ s.green().on_yellow().green().on_yellow().to_string()
+ );
+ }
+}