Skip to content

[MSHARED-687] Programmatic read-only access to Color API #336

@jira-importer

Description

@jira-importer

Guillaume Boué opened MSHARED-687 and commented

We should provide a way to access programmatically the Color API, without being JAnsi specific. Read-only should suffice for now, as the styles can be changed through system properties. This would allow tools, like the Help Plugin, to interact with it without depending on the implementation.

  • Refactor JAnsi specific code currently in Style into AnsiMessageBuilder.
  • Make Style part of public API, and add getters boolean isBold(), boolean isBright(), String getColor(), boolean isBgBright() and String getBgColor().
  • Document Style.toString() to return a comma-separated list of the style components (e.g. bold,red).
  • Add a public List<String> getAvailableColorNames() method to MessageUtils. Today, it would return the list of color names in the enum Ansi.Color if JAnsi is present, otherwise an empty list.

With those changes, a consumer could for example do:

MessageUtils.buffer().success( Style.SUCCESS.toString() )

in order to print the String representation of success with its own style, while not depending on JAnsi.


Affects: maven-shared-utils-3.2.1

Issue Links:

  • MPH-122 add help:color-style goal to describe styles color
    ("is required by")

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:minorMinor loss of function, or other problem where easy workaround is present

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions