Add optional colorized output support
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 262
- Forks
- 228
- Avg merge
- 23h 15m
- Merged PRs (30d)
- 12
Description
Description
This issue adds optional colorized terminal output to ros2cli. Colorization is off by default and can be enabled in two ways:
- Set the environment variable
ROS_COLORIZED_OUTPUT=1(requires stdout to be a TTY) - Pass the
--colorflag on the command line (e.g.ros2 --color topic echo /chatter)
Motivation
ros2cli output — especially from commands like ros2 topic echo, ros2 interface show, and ros2 param dump — is often dense, structured text (YAML, IDL, key-value pairs). Without color, it is difficult to quickly distinguish field names from values, ROS type strings from plain text, or section headers from content. Colorized output is a standard ergonomic feature in modern CLI tools and has been a recurring community request.
Design / Implementation Considerations
Modified: ros2cli/cli.py
- Adds
--colorCLI argument - Activates
ColoringStdoutwrapping when color is enabled, selecting the appropriate colorizer for the active command/verb
New file: ros2cli/color.py
- Introduces a
Colorizerbase class and an extensible registry keyed by(command, verb)pairs DefaultColorizerapplies generic ANSI heuristics (ROS paths, type strings, YAML keys) as a fallback for unregistered commandsColoringStdoutwrapssys.stdoutand colorizes output line-by-line- Built-in colorizers registered for:
ros2(help),topic echo,topic hz,topic bw,topic info,param get,param dump,interface show,component list - Third-party packages can register custom colorizers via
ros2cli.color.register(command, verb, colorizer)
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ros2cli/cli.py to trace argument handling and stdout setup, then review the proposed ros2cli/color.py interfaces and registered command/verb pairs. Verify that both ROS_COLORIZED_OUTPUT=1 and --color enable TTY-aware colorization, while default output remains unchanged across the listed commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100