Problem
When integrating codedash into CI pipelines (e.g., GitHub Actions), users need to generate badge data (shields.io endpoint JSON) for README badges. Currently this requires writing custom Python/shell scripts to parse codedash analyze -o json output and produce the correct JSON format.
Badge generation is a standard responsibility of metrics tools (e.g., cargo-tarpaulin --out badge), and codedash should support it natively.
Proposed Solution
Add a badge subcommand that outputs shields.io Endpoint Badge JSON files.
CLI Interface
codedash badge [OPTIONS] [path]
Arguments:
[path] Source directory (default: .)
Options:
-o, --out-dir <dir> Output directory (default: ./badges)
-c, --config <config> Config file path (.codedash.lua)
--cov-file <cov-file> Coverage JSON (cargo llvm-cov --json)
--format <format> Badge format: shields-endpoint (default), svg
--only <metrics> Comma-separated filter: coverage,fn-coverage,complexity,modules
Example Usage
codedash badge . --cov-file coverage.json -o _site/badges/
Output Files
badges/
coverage.json # line coverage %
fn-coverage.json # function coverage %
complexity.json # avg/max cyclomatic complexity
modules.json # total code units
Each file follows the shields.io endpoint format:
{
"schemaVersion": 1,
"label": "coverage",
"message": "86.3%",
"color": "brightgreen"
}
Color Logic
| Metric |
Green |
Yellow |
Red |
| coverage |
>= 80% |
>= 60% |
< 60% |
| fn-coverage |
>= 80% |
>= 60% |
< 60% |
| complexity (avg) |
<= 5 |
<= 10 |
> 10 |
| modules |
always blue |
— |
— |
Configuration Override
Thresholds should be overridable via .codedash.lua:
return {
extends = "recommended",
badges = {
coverage = { green = 80, yellow = 60 },
complexity = { green = 5, yellow = 10 },
},
}
CI Integration (Before/After)
# Before: custom Python script required
- run: |
python3 <<'PY'
import json
cov = json.load(open("coverage.json"))
# ... 20+ lines of badge generation logic
PY
# After: single command
- run: codedash badge . --cov-file coverage.json -o _site/badges/
README Badge Embedding


Future Extensions
--format svg: self-contained SVG badge generation (no shields.io dependency)
- Auto-embed badges into
codedash view HTML output
- Custom badge definitions in
.codedash.lua badges section
Problem
When integrating codedash into CI pipelines (e.g., GitHub Actions), users need to generate badge data (shields.io endpoint JSON) for README badges. Currently this requires writing custom Python/shell scripts to parse
codedash analyze -o jsonoutput and produce the correct JSON format.Badge generation is a standard responsibility of metrics tools (e.g.,
cargo-tarpaulin --out badge), and codedash should support it natively.Proposed Solution
Add a
badgesubcommand that outputs shields.io Endpoint Badge JSON files.CLI Interface
Example Usage
codedash badge . --cov-file coverage.json -o _site/badges/Output Files
Each file follows the shields.io endpoint format:
{ "schemaVersion": 1, "label": "coverage", "message": "86.3%", "color": "brightgreen" }Color Logic
Configuration Override
Thresholds should be overridable via
.codedash.lua:CI Integration (Before/After)
README Badge Embedding
Future Extensions
--format svg: self-contained SVG badge generation (no shields.io dependency)codedash viewHTML output.codedash.luabadgessection