cli_help.py is a Bazel tool designed to discover and display Bazel targets that have been tagged with cli_help tags. This tool helps developers quickly find available command-line tools and their descriptions within a Bazel workspace.
- Discovers Bazel targets across the entire workspace and external repositories
- Filters targets by
cli_helptags to identify command-line tools - Provides a clean, formatted output with target names and descriptions
- Color-coded output for better readability
- Python 3.6+
- Bazel build system
os,re,subprocess, andxml.etree.ElementTree(standard library modules)
To use cli_help.py, simply clone this repository and ensure it's properly integrated into your Bazel workspace.
The script can be run from the command line using Bazel:
bazel run //tooling/cli_helper/tool:help- Workspace Discovery: The tool automatically detects the current Bazel workspace directory
- Target Discovery: Queries Bazel for all targets across the workspace and external repositories
- Tag Filtering: Filters targets that have
cli_helptags - Output Formatting: Displays target names and their associated help descriptions
The tool outputs a formatted list of targets with their descriptions:
BAZEL TARGETS:
//tooling/cli_helper/tool:help CLI helper tool for discovering Bazel targets
//some/other/tool:binary Another tool description
To make your Bazel targets discoverable by this tool, add a cli_help tag to your target definitions:
py_binary(
name = "my_tool",
srcs = ["my_tool.py"],
tags = ["cli_help=My tool description"],
visibility = ["//visibility:public"],
)The cli_help tag should follow this format:
cli_help=<description>where<description>is a human-readable description of what the tool does
To integrate the CLI helper into your Bazel-based project, you can use Bazel modules.
Add the following to your MODULE.bazel:
bazel_dep(name = "score_cli_helper", version = "0.1.0")Add the following to you BUILD:
load("@score_cli_helper//:cli_helper.bzl", "cli_helper")
cli_helper(
name = "cli-help",
visibility = ["//visibility:public"],
)Once integrated, you can run the tool using:
bazel run //:help# Run from the workspace root
bazel run //:helpBAZEL TARGETS:
//tooling/cli_helper/tool:help CLI helper tool for discovering Bazel targets
//tooling/cr_checker/tool:cr_checker Copyright header checker and fixer
//tooling/format_checker/tool:format_checker Code formatting verification tool
- Discoverability: Easily find available command-line tools in your workspace
- Documentation: Provides inline descriptions for tools
- Workspace Navigation: Helps developers understand what tools are available
- Integration: Seamlessly integrates with Bazel's build system