From 739b346722c97a59ff082be9dec5aa84613ef295 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 24 Apr 2017 01:13:57 +0200 Subject: Extend the readme --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index f74be3e..5297220 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,63 @@ # Config A perl 6 library for reading and writing configuration files. +## Installation +This module can be installed using `zef`: + +``` +zef install Config +``` + +Depending on the type of configuration file you want to work on, you will need a +`Config::Parser::` module as well. If you just want an easy-to-use configuration +object without reading/writing a file, no parser is needed. + +## Usage +Include the `Config` module in your script, instantiate it and use it as you +please. + +```perl6 +use Config; + +my $config = Config.new(); + +# loading a simple configuration hash +$config.read({ + keyOne => "value", + keyTwo => { + NestedKey => "other value" + } +}); + +# loading a configuration files +$config.read("/etc/config.yaml"); + +# retrieving a simple key +$config.get("keyOne"); + +# retrieving a nested key +$config.get("keyTwo.NestedKey"); +``` + +### Available parsers +Because there's so many ways to structure your configuration files, the parsers +for these are their own modules. This allows for easy implementing new parsers, +or providing a custom parser for your project's configuration file. + +The parser will be loaded during runtime, but you have to make sure it is +installed yourself. + +The following parsers are available: + +- [`Config::Parser::yaml`](https://github.com/scriptkitties/p6-Config-Parser-yaml) + +### Writing your own parser +If you want to make your own parser, simply make a new class in the +`Config::Parser` namespace. This class should extend the `Config::Parser` class, +and implement the `read` and `write` methods. The `read` method *must* return a +`Hash`. The `write` method *must* return a `Bool`, `True` when writing was +successful, `False` if not. + ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software -- cgit v1.1