3.26. kink/conf/CONF

Mod to read conf vals. See CONF.read.

3.26.1. CONF.read($config_target $config_read)

CONF.read reads a conf val from $config_target, with settings configured by $config_read.

Example:

:CONF.require_from('kink/conf/')

:open_file <- {(:Config.opt)
  :config = Config.just_or{ {} }
  :Map = CONF.read($config){(:Rc)
    Rc.no_arg('append')
    Rc.opt_arg('buffer' 2048)
    Rc.req_arg('newline')
  }

  :Append? = Map.have_key?('append')
  stdout.print('Append? = {}'.format(Append?.repr))

  Map.get_maybe('buffer').for_maybe(
    {(:Buf_size)
      stdout.print(', Buffer size = {}'.format(Buf_size))
    }
    { stdout.print(', No buffer') }
  )

  Map.get_maybe('newline').for_maybe(
    {(:Newline)
      stdout.print(', Newline = {}'.format(Newline.repr))
    }
    { stdout.print_line(', No newline') }
  )
}

open_file
# => Append? = false, No buffer, No newline

open_file{(:C)
  C.append
  C.buffer(1024)
  C.newline("\n")
}
# => Append? = true, Buffer size = 1024, Newline = "\n"

open_file{(:C)
  C.buffer
}
# => Append? = false, Buffer size = 2048, No newline