From 2950c8556ac831c220170e8407661bab0338750c Mon Sep 17 00:00:00 2001 From: albfan Date: Wed, 13 May 2015 22:24:48 +0200 Subject: [PATCH] better documentation --- README.md | 44 ++++++++++++++----- test/test.sh => scripts/example.sh | 0 {test => scripts}/file.ini | 0 .../getkeyfromsection.sh | 0 4 files changed, 33 insertions(+), 11 deletions(-) rename test/test.sh => scripts/example.sh (100%) rename {test => scripts}/file.ini (100%) rename test/testfile.sh => scripts/getkeyfromsection.sh (100%) diff --git a/README.md b/README.md index 845bd13..9841032 100644 --- a/README.md +++ b/README.md @@ -2,37 +2,59 @@ A ini file parser for bash relying only on builtins -### Using +### Usage -You must copy bash-ini-parser on your project and source it +You must copy [bash-ini-parser](https://github.com/albfan/bash-ini-parser/blob/master/bash-ini-parser) on your project and source it: $ source bash-ini-parser or - $ . source bash-ini-parser + $ . bash-ini-parser -It will declare functions per section called cfg.section.
with variable declaration inside so you can access its values using +Then, gived a properties file (file.ini): + + [section] + key = value + key2 = value2 + +Issuing: + + $ cfg_parser file.ini + +Will declare functions per ini section called cfg.section.
which declares variables named as keynames so you can access its values using $ cfg.section.
- $ echo $var + $ echo $key + value + $ echo $key2 + value2 -### test it +### Example -Goto test directory and launch test.sh +Goto scripts directory and launch [example.sh](https://github.com/albfan/bash-ini-parser/blob/master/scripts/example.sh) - $ cd test - $ ./test.sh + $ cd scripts + $ ./example.sh Inspect its code, reuse on your scripts -If you want to test your existing ini file use testfile.sh +### Checking a ini file - $ testfile.sh >customfile.ini< sectionname varname +If you want to test your existing ini file use [getkeyfromsection.sh](https://github.com/albfan/bash-ini-parser/blob/master/scripts/getkeyfromsection.sh) + + $ getkeyfromsection.sh sectionname keyname e.g.: +See [file.ini](https://github.com/albfan/bash-ini-parser/blob/master/scripts/file.ini), it is a file with different indentations, and comments + +Issuing: + $ ./testfile.sh file.ini sec1 var4 + +Outputs: + show parsed file.ini [sec1] var1="foo" diff --git a/test/test.sh b/scripts/example.sh similarity index 100% rename from test/test.sh rename to scripts/example.sh diff --git a/test/file.ini b/scripts/file.ini similarity index 100% rename from test/file.ini rename to scripts/file.ini diff --git a/test/testfile.sh b/scripts/getkeyfromsection.sh similarity index 100% rename from test/testfile.sh rename to scripts/getkeyfromsection.sh