aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-24 01:13:57 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:06 +0200
commit739b346722c97a59ff082be9dec5aa84613ef295 (patch)
treef4e6d1d0374b344ad9040ee5b9a5b819205e2236 /README.md
parent3df3e92fd342e7a9951970b5c91cb88274d653da (diff)
Extend the readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md57
1 files changed, 57 insertions, 0 deletions
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