Skip to content

nochso/ctxerr

Repository files navigation

ctxerr

MIT license GoDoc GitHub release Go Report Card Build Status Coverage Status

ctxerr is a Go library and CLI utility for pretty-printing linter/parser errors.

Instead of just describing what's wrong, it lets you point at the wrong input:

narf.txt:1:8: string is missing closing quote
 1 | "foo bar
   |         ^ missing closing quote
  • Create pretty error messages for linters, parsers, etc. by pointing at the relevant position in the source code.
  • Parse existing error messages into Ctx structs.
  • CLI utility ctx scans STDIN for linter errors and enhances them with the reported source line.

Installation

Library

go get -u github.com/nochso/ctxerr

CLI utility ctx

go install github.com/nochso/ctxerr/cmd/ctx

Documentation

Library

The GoDoc pages contain plenty of examples.

CLI utility ctx

$ ctx -h
ctx 1.0.0-beta
Pretty prints parser errors from stdin.

Possible input:
  path/file.ext:1:5: some error on line 1, column 5
  file.ext:123: column is optional and so is the message:
  file.ext:1

Usage:
  ctx < log.txt
  gometalinter . | ctx

Flags:
  -context NUM
        print NUM lines of context surrounding an error. negative for all, positive for limited and 0 for none (default)
  -no-color
        disable any color output
  -pessimistic
        print only matching errors, ignore everything else

Changes

All notable changes to this project will be documented in the changelog.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

License

This project is released under the MIT license.

About

ctxerr is a Go library for printing pretty parser errors.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages