shields.io badge generator implemented as an mq module — build badge URLs and ready-to-paste Markdown image tags for READMEs without leaving your mq pipeline.
- Builds shields.io static badge URLs, with correct escaping of
-,_, and spaces - Renders a ready-to-paste Markdown badge, optionally wrapped in a link
status_colormaps common CI status words (passing,failing,unknown, …) to shields.io colorsbuild/license/versionconvenience wrappers for the most common badges
Copy badge.mq to your mq module directory, or place it anywhere and reference it with -L.
cp badge.mq ~/.local/mq/config/If mq was built with the http-import feature, you can import directly from GitHub without any local setup:
mq -I raw 'import "github.com/harehare/badge.mq" | badge::license("MIT")' <<< "x"Pin to a specific release with @vX.Y.Z:
mq -I raw 'import "github.com/harehare/badge.mq@v0.1.0" | ...'mq -L /path/to/modules -I raw \
'import "badge" | badge::markdown("build", "passing", "brightgreen")' <<< "x"If you copied it to the mq built-in module directory:
mq -I raw 'import "badge" | badge::markdown("build", "passing", "brightgreen")' <<< "x"| Function | Description |
|---|---|
url(label, message, color = "blue", style = None, logo = None) |
Builds a shields.io badge URL |
markdown(label, message, color = "blue", link = None, style = None, logo = None) |
Builds a Markdown  badge, optionally wrapped in [...](link) |
status_color(status) |
Maps a status word to a shields.io color (passing/success/ok -> brightgreen, failing/error/fail -> red, unknown -> lightgrey, else yellow) |
build(status, style = None) |
A build-status badge with color derived from status_color |
license(name, color = "blue", style = None) |
A license: name badge |
version(v, color = "blue", style = None) |
A version: v badge |
color accepts either a named shields.io color (blue, brightgreen, red, …) or a
hex code, with or without the leading #. style is one of shields.io's badge
styles (flat, flat-square, plastic, for-the-badge, social).
Note: Only shields.io's own
-/_/space escaping is applied — other characters that are special in URLs (%,?,&,/, …) are passed through as-is. This covers the vast majority of real-world labels/messages; if yours contains other reserved characters, percent-encode it yourself before callingurl/markdown.
mq -I raw 'import "badge" | badge::url("coverage", "92%", "green", "flat-square")' <<< "x"
# => "https://img.shields.io/badge/coverage-92%-green?style=flat-square"
mq -I raw 'import "badge" | badge::markdown("license", "MIT", "blue", "https://opensource.org/licenses/MIT")' <<< "x"
# => "[](https://opensource.org/licenses/MIT)"
mq -I raw 'import "badge" | badge::build("passing")' <<< "x"
# => ""Requires mq v0.6 or later.
MIT