Casperjs API-colorizer Module

Source: Internet
Author: User

Casperjs API-colorizer Module
The colorizer module contains a Colorizer class that can generate a standardized color string: var colorizer = require ('colorizer '). create ('colorizer'); console. log (colorizer. colorize ("Hello World", "INFO"); in most cases, you will use it using the CASPER echo () method. Casper. echo ('an Ive message', 'info'); // printed in greencasper. echo ('an error message', 'error'); // printed in red ignores casperjs style options: if you do not need to set the color, you only need to set the colorizerType to Dummy: var casper = require ('casper '). create ({colorizerType: 'dummy'}); casper. echo ("Hello", "INFO"); note: this is especially useful if casperjs is used on Windows, color output of available predefined styles is not supported on windows platforms: available predefined styles include: ERROR: White Red Bottom INFO: green text TRACE: green text PARAMETER: cyan text COMM ENT: yellow text WARNING: red text GREEN_BAR: white text RED_BAR: white text INFO_BAR: blue text WARN_BAR: white text The following is an example: colorizer colorize () Signature: colorize (String text, String styleName) calculates the text String provided by a color version and uses a given predefined style: var colorizer = require ('colorizer '). create (); console. log (colorizer. colorize ("I'm a red error", "ERROR"); Note: you do not need to use a colorizer instance most of the time. casperjs provides all the necessary methods. Format () Signature: format (String text, Object style) format a String using the provided style. A style definition is a standard javascript Object with the following attributes: String bg: background color name String fg: foreground color name Boolean bold: the bold format Boolean underscore is applied: underline format Boolean blink: flashing format Boolean reverse: Apply reverse format Boolean conceal: Use a hidden format to indicate that the optional color names are black, red, green, yellow, blue, magenta, cyan and white: var colorizer = require ('colorizer '). create (); colorizer. format ("We all live in a yellow submarine", {bg: 'yellow', fg: 'blue', bold: true });

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.