Skip to content

Migrate from termcolor to anstream #12627

Closed
@epage

Description

@epage

anstream provides the same feature set as termcolor (including legacy windows support) but with a less awkward API to work with. Instead of hand-constructing data in a special container with each step requiring setting the style, you use whatever styling library you like (e.g. color-print like in #12578) and then write to the appropriate stream, and you are done. The stream does all the rest, allowing styling to be decoupled from where it is being rendered.

So anstream would replace

  • termcolor
  • fwdansi
  • strip-ansi-escapes

Benefits

  • Lower boilerplate way to style text while leaving Shell in control (see cargo adds use of Shell::write_stderr)
  • Open the door for styling within messages
  • Lower overhead as it only intercepts when something needs changing. This will be especially true in switching from fwdansi to anstream
  • Strip API is significantly faster than strip-ansi-escapes
  • Centralize color schemes between Shell (currently using termcolor) and clap (using anstyle)

Metadata

Metadata

Assignees

Labels

A-cliArea: Command-line interface, option parsing, etc.A-console-outputArea: Terminal output, colors, progress bar, etc.C-cleanupCategory: cleanup within the codebase

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions