scribe v0.6.0 Scribe View Source

Pretty-print tables of structs and maps

Link to this section Summary

Types

Options for configuring table output

Functions

Formats data into a printable table string

Prints a table from given data and returns the data

Prints a table from given data

Link to this section Types

Link to this type data() View Source
data() :: [] | [...] | term()
Link to this type format_opts() View Source
format_opts() :: [colorize: boolean(), data: [...], style: module(), width: integer()]

Options for configuring table output.

  • :colorize - When false, disables colored output. Defaults to true
  • :data - Defines table headers
  • :style - Style callback module. Defaults to Scribe.Style.Default
  • :width - Defines table width. Defaults to :infinite

Link to this section Functions

Link to this function console(results, opts \\ nil) View Source
Link to this function format(results, opts \\ []) View Source

Formats data into a printable table string.

Examples

iex> format([])
:ok

iex> format(%{test: 1234}, colorize: false)
"+---------+\n| :test   |\n+---------+\n| 1234    |\n+---------+\n"
Link to this function inspect(results, opts \\ []) View Source
inspect(term(), format_opts()) :: term()

Prints a table from given data and returns the data.

Useful for inspecting pipe chains.

Examples

iex> Scribe.inspect([])
[]

iex> Scribe.inspect(%{key: :value, test: 1234}, colorize: false)
+----------+---------+
| :key     | :test   |
+----------+---------+
| :value   | 1234    |
+----------+---------+
%{test: 1234, key: :value}
Link to this function print(results, opts \\ []) View Source
print(data(), format_opts()) :: :ok

Prints a table from given data.

Examples

iex> print([])
:ok

iex> Scribe.print(%{key: :value, test: 1234}, colorize: false)
+----------+---------+
| :key     | :test   |
+----------+---------+
| :value   | 1234    |
+----------+---------+
:ok