/decorator

A Go library used to make inline, user friendly messages.

Primary LanguageGoMIT LicenseMIT

Overview

Go Reference Go Report Card Codacy Badge

Decorator is a simple library for adding comments onto lines of text, primarily aimed at user-friendly error messages.

For example:

image

The above output was generated from the following code:

  var d Decorator
	
  d.AddLine("printf(\"%s\", 400)", LineMetadata{FileName: "main.c", LineNumber: 5})
  d.ColourLine(0, LineColour{From: 0, To: 6, Colour: FgYellow})
  d.ColourLine(0, LineColour{From: 7, To: 11, Colour: FgMagenta})
  d.ColourLine(0, LineColour{From: 13, To: 16, Colour: FgCyan})

  d.AddTopComment(0, 8, "%s was specified.")
  d.ColourTopComment(0, 0, LineColour{From: 0, To: 3, Colour: FgGreen})

  d.AddBottomComment(0, 13, "But a %d value was passed")
  d.ColourBottomComment(0, 0, LineColour{From: 6, To: 8, Colour: FgRed})
  
  print(d.String())

yada yada TODO