Skip to content

Commit

Permalink
update 'anyconfig_cli --help' output and add an example of ignore_mis…
Browse files Browse the repository at this point in the history
…sing use case in REAMDE
  • Loading branch information
ssato committed Oct 25, 2014
1 parent d0f7391 commit a3eb147
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ To load multiple config files::
# Specify config files by list of paths:
data1 = anyconfig.load(["/etc/foo.d/a.json", "/etc/foo.d/b.json"])

# Similar to the above but all or one of config files are missing:
data2 = anyconfig.load(["/etc/foo.d/a.json", "/etc/foo.d/b.json"],
ignore_missing=True)

# Specify config files by glob path pattern:
data2 = anyconfig.load("/etc/foo.d/*.json")
data3 = anyconfig.load("/etc/foo.d/*.json")

# Similar to above, but parameters in the former config file will be simply
# Similar to the above, but parameters in the former config file will be simply
# overwritten by the later ones:
data3 = anyconfig.load("/etc/foo.d/*.json", merge=anyconfig.MS_REPLACE)
data4 = anyconfig.load("/etc/foo.d/*.json", merge=anyconfig.MS_REPLACE)

On loading multiple config files, you can choose 'strategy' to merge
configurations from the followings:
Expand Down Expand Up @@ -208,51 +212,58 @@ There is a CLI frontend 'anyconfig_cli' to demonstrate the power of this library

It can process various config files and output a merged config file::

$ anyconfig_cli -h
ssato@localhost% anyconfig_cli -h
Usage: anyconfig_cli [Options...] CONF_PATH_OR_PATTERN_0 [CONF_PATH_OR_PATTERN_1 ..]

Examples:
anyconfig_cli --list
anyconfig_cli -I yaml /etc/xyz/conf.d/a.conf
anyconfig_cli -I yaml -O yaml /etc/xyz/conf.d/a.conf
anyconfig_cli -I yaml '/etc/xyz/conf.d/*.conf' -o xyz.conf --otype json
anyconfig_cli '/etc/xyz/conf.d/*.json' -o xyz.yml \
--atype json -A '{"obsoletes": "sysdata", "conflicts": "sysdata-old"}'
anyconfig_cli '/etc/xyz/conf.d/*.json' -o xyz.yml \
-A obsoletes:sysdata;conflicts:sysdata-old
anyconfig_cli /etc/foo.json /etc/foo/conf.d/x.json /etc/foo/conf.d/y.json
anyconfig_cli '/etc/foo.d/*.json' -M noreplace
anyconfig_cli '/etc/foo.d/*.json' --get a.b.c
anyconfig_cli '/etc/foo.d/*.json' --set a.b.c=1

Options:
--version show program's version number and exit
-h, --help show this help message and exit
-L, --list List supported config types
-o OUTPUT, --output=OUTPUT
Output file path
-I ITYPE, --itype=ITYPE
Select type of Input config files from ini, json,
yaml, xml [Automatically detected by file ext]
Select type of Input config files from ini, json, xml,
yaml [Automatically detected by file ext]
-O OTYPE, --otype=OTYPE
Select type of Output config files from ini, json,
yaml, xml [Automatically detected by file ext]
xml, yaml [Automatically detected by file ext]
-M MERGE, --merge=MERGE
Select strategy to merge multiple configs from
noreplace, merge_dicts_and_lists, merge_dicts, replace
replace, noreplace, merge_dicts, merge_dicts_and_lists
[merge_dicts]
-A ARGS, --args=ARGS Argument configs to override
--atype=ATYPE Explicitly select type of argument config from ini,
json, yaml, xml. If this option is not set, original
parser is used: 'K:V' will become {K: V},
--atype=ATYPE Explicitly select type of argument to provide configs
from ini, json, xml, yaml. If this option is not set,
original parser is used: 'K:V' will become {K: V},
'K:V_0,V_1,..' will become {K: [V_0, V_1, ...]}, and
'K_0:V_0;K_1:V_1' will become {K_0: V_0, K_1: V_1}
(where the tyep of K is str, type of V is one of Int,
str, etc.
--get=GET Specify key path to get part of config, for example,
if a config {'a': {'b': {'c': 0, 'd': 1}}} '--get
a.b.c' gives 0 and '--get a.b' gives {'c': 0, 'd': 1}.
--get=GET Specify key path to get part of config, for example, '
--get a.b.c' to config {'a': {'b': {'c': 0, 'd': 1}}}
gives 0 and '--get a.b' to the same config gives {'c':
0, 'd': 1}.
--set=SET Specify key path to set (update) part of config, for
example, '--set a.b.c=1' to a config {'a': {'b': {'c':
0, 'd': 1}}} gives {'a': {'b': {'c': 1, 'd': 1}}}.
-x, --ignore-missing Ignore missing input files
-s, --silent Silent or quiet mode
-q, --quiet Same as --silent option
-v, --verbose Verbose mode
$

ssato@localhost%

Build & Install
================
Expand Down

0 comments on commit a3eb147

Please sign in to comment.