fmt: format lua types

The fmt module is a small module which formats arbitrary lua types as well as enables users to define formatting for their own metatypes via the :__fmt(fmter) method.

It also provides several helper methods such as print, assertf and errorf, making it more convienent to print or format types. In addition, it sets io.fmt = io.fmt or Fmt{to=io.stderr}, providing a default hook for ds.html#ds.log and command line utilities to write formatted text to.

The #fmt.Fmt interface (which is passed to a metaty's __fmt method if present) accepts both :write(...) (like a file) and :styled("style", "styled text", ..."non-styled text"), enabling the asciicolor library (or your own library!) to provide user-configurable colors for specific styles which integrate with the vt100 library and the cxt libraries. This is used throughout civstack to provide user-configurable (and optional) color to the terminal, web-pages and the ele editor.

Mod fmt

format module: format any type into a readable string

Types: Fmt

Functions

Record Fmt

The formatter object.

This is the main API of this module. It enables formatting any type by simply calling it's instance, writing the result to to (if set) or just the fmter itself. For the latter, you can construct the string with fmter:tostring() or just table.concat(fmter).

Fields:

Methods

Command fmt.binary

Library to format binary text.

Cmd usage: seebin path/to/file.bin Arguments:

Methods and Functions