pint.error --no-color lint rules
! stdout .
cmp stderr stderr.txt

-- stderr.txt --
level=info msg="Loading configuration file" path=.pint.hcl
level=info msg="File parsed" path=rules/0001.yml rules=5
level=info msg="File parsed" path=rules/0002.yml rules=1
rules/0001.yml:1-2: url annotation is required (alerts/annotation)
- alert: Always
  expr: up

rules/0001.yml:1-2: severity label is required (rule/label)
- alert: Always
  expr: up

rules/0001.yml:2: alert query doesn't have any condition, it will always fire if the metric exists (promql/comparison)
  expr: up

rules/0001.yml:9-10: url annotation is required (alerts/annotation)
- alert: ServiceIsDown
  expr: up == 0

rules/0001.yml:9-10: severity label is required (rule/label)
- alert: ServiceIsDown
  expr: up == 0

rules/0001.yml:14: severity label value must match regex: ^critical|warning|info$ (rule/label)
    severity: bad

rules/0001.yml:16: url annotation value must match regex: ^https://wiki.example.com/page/(.+).html$ (alerts/annotation)
    url: bad

rules/0002.yml:5: template parse error: undefined variable "$label" (alerts/template)
    summary: 'Instance {{ $label.instance }} down'

rules/0002.yml:6: template parse error: undefined variable "$valuexx" (alerts/template)
    func: '{{ $valuexx | xxx }}'

rules/0002.yml:9: template parse error: undefined variable "$label" (alerts/template)
    summary: 'Instance {{ $label.instance }} down'

rules/0002.yml:10: template parse error: function "xxx" not defined (alerts/template)
    func: '{{ $value | xxx }}'

rules/0002.yml:11: using $value in labels will generate a new alert on every value change, move it to annotations (alerts/template)
    bar: 'Some {{$value}} value'

rules/0002.yml:12: using .Value in labels will generate a new alert on every value change, move it to annotations (alerts/template)
    val: '{{ .Value|humanizeDuration }}'

level=info msg="Problems found" Bug=5 Fatal=4 Warning=4
level=fatal msg="Fatal error" error="problems found"
-- rules/0001.yml --
- alert: Always
  expr: up
- alert: AlwaysIgnored
  expr: up # pint disable promql/comparison
  labels:
    severity: warning
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"
- alert: ServiceIsDown
  expr: up == 0
- alert: ServiceIsDown
  expr: up == 0
  labels:
    severity: bad
  annotations:
    url: bad
- alert: ServiceIsDown
  expr: up == 0
  labels:
    severity: warning
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"

-- rules/0002.yml --
- alert: Foo Is Down
  expr: up{job="foo"} == 0
  annotations:
    url: "https://wiki.example.com/page/ServiceIsDown.html"
    summary: 'Instance {{ $label.instance }} down'
    func: '{{ $valuexx | xxx }}'
  labels:
    severity: warning
    summary: 'Instance {{ $label.instance }} down'
    func: '{{ $value | xxx }}'
    bar: 'Some {{$value}} value'
    val: '{{ .Value|humanizeDuration }}'
    ignore: '$value is not a variable'

-- .pint.hcl --
rule {
    annotation "url" {
        severity = "bug"
        value = "https://wiki.example.com/page/(.+).html"
        required = true
    }
    label "severity" {
        value = "critical|warning|info"
        required = true
    }
}
