Penlight Documentation

# Module `pl.config`

Reads configuration files into a Lua table.

Understands INI files, classic Unix config files, and simple delimited columns of values. See the Guide

    # test.config
    # Read timeout in seconds
    read.timeout=10
    # Write timeout in seconds
    write.timeout=5
    #acceptable ports
    ports = 1002,1003,1004

    -- readconfig.lua
    local config = require 'config'
    local t = config.read 'test.config'
    print(pretty.write(t))

    ### output #####
    {
      ports = {
        1002,
        1003,
        1004
      },
      write_timeout = 5,
      read_timeout = 10
    }

## Functions

lines (file) | like io.lines(), but allows for lines to be continued with ''.
read (file[, cnfg]) | read a configuration file into a table

## Functions

lines (file)
  like io.lines(), but allows for lines to be continued with ''.

  ### Parameters:

  - file a file-like object (anything where read() returns the next line) or a filename. Defaults to stardard input.

  ### Returns:

  1. an iterator over the lines, or nil
  2. error 'not a file-like object' or 'file is nil'
read (file[, cnfg])
  read a configuration file into a table

  ### Parameters:

  - file either a file-like object or a string, which must be a filename
  - cnfg tab

    a configuration table that may contain these fields:

    - `smart` try to deduce what kind of config file we have (default false)
    - `variabilize` make names into valid Lua identifiers (default true)
    - `convert_numbers` try to convert values into numbers (default true)
    - `trim_space` ensure that there is no starting or trailing whitespace with values (default true)
    - `trim_quotes` remove quotes from strings (default false)
    - `list_delim` delimiter to use when separating columns (default ',')
    - `keysep` separator between key and value pairs (default '=')
    (optional)

  ### Returns:

  1. a table containing items, or `nil`
  2. error message (same as config.lines

generated by LDoc 1.4.6