diff --git a/carom/cli.py b/carom/cli.py index cc0bbc6..2324b70 100644 --- a/carom/cli.py +++ b/carom/cli.py @@ -2,6 +2,7 @@ import click from click_didyoumean import DYMGroup import click_log import logging + logger = logging.getLogger('carom.cli') # hard coded module name to support directly called module root_logger = logging.getLogger('') click_log.basic_config(root_logger) @@ -21,5 +22,19 @@ def run(): pass +@cli.command() +def check_config(): + """ + This command checks the config for carom client. + """ + from carom.config import config, log_config + if config: + logger.info("Configuration OK") + else: + logger.warning("Compiled configuration:") + log_config() + exit(1) + + if __name__ == "__main__": cli() diff --git a/carom/client.ini b/carom/client.ini index 2c6062d..632d949 100644 --- a/carom/client.ini +++ b/carom/client.ini @@ -1,2 +1,3 @@ [test] -foo = bar \ No newline at end of file +foo = bar +bar = foo \ No newline at end of file diff --git a/carom/config.py b/carom/config.py index aca661a..b22a1fc 100644 --- a/carom/config.py +++ b/carom/config.py @@ -23,4 +23,14 @@ try: config = validate_with_humanized_errors(_parser_dict, _schema) except Error as e: logger.error('Failed to validate the configuration:\n{}'.format(e)) -__all__ = ('config', ) + config = None + + +def log_config(): + for s in _parser.sections(): + logger.warning("[{}]".format(s)) + for i in _parser.items(s): + logger.warning("{} = {}".format(*i)) + + +__all__ = ('config', 'log_config') diff --git a/doc/developement.rst b/doc/developement.rst deleted file mode 100644 index 06cca88..0000000 --- a/doc/developement.rst +++ /dev/null @@ -1,9 +0,0 @@ -Developement -============ - -Update der Manpages -------------------- - -.. code-block:: bash - - pipenv run sphinx-build -b man doc doc/man \ No newline at end of file diff --git a/doc/development.rst b/doc/development.rst new file mode 100644 index 0000000..7680c0d --- /dev/null +++ b/doc/development.rst @@ -0,0 +1,16 @@ +Development +=========== + +Starten der Scripts zu Entwicklung +---------------------------------- + +.. code-block:: bash + + pipenv run python -m carom.cli + +Update der Manpages +------------------- + +.. code-block:: bash + + pipenv run sphinx-build -b man doc doc/man \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index 9b02056..402c81b 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -12,7 +12,7 @@ Welcome to Carom Client's documentation! api/index man - developement + development diff --git a/doc/man/carom-client.1 b/doc/man/carom-client.1 index 74e7b6f..cdf1b7c 100644 --- a/doc/man/carom-client.1 +++ b/doc/man/carom-client.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "CAROM-CLIENT" "1" "04.11.2018" "" "Carom Client" +.TH "CAROM-CLIENT" "1" "05.11.2018" "" "Carom Client" .SH NAME carom-client \- Carom Client Documentation . @@ -45,6 +45,19 @@ Options.INDENT 0.0 .B \-v, \-\-verbosity Either CRITICAL, ERROR, WARNING, INFO or DEBUG .UNINDENT +.SH CHECK-CONFIG +.sp +This command checks the config for carom client. +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +carom\-client check\-config [OPTIONS] +.ft P +.fi +.UNINDENT +.UNINDENT .SH RUN .sp This command runs the carom\-client daemon process.