Added check-config command

This commit is contained in:
Alexander Werner 2018-11-05 19:04:19 +01:00
parent b534b0e523
commit 58ba549227
7 changed files with 59 additions and 13 deletions

View File

@ -2,6 +2,7 @@ import click
from click_didyoumean import DYMGroup from click_didyoumean import DYMGroup
import click_log import click_log
import logging import logging
logger = logging.getLogger('carom.cli') # hard coded module name to support directly called module logger = logging.getLogger('carom.cli') # hard coded module name to support directly called module
root_logger = logging.getLogger('') root_logger = logging.getLogger('')
click_log.basic_config(root_logger) click_log.basic_config(root_logger)
@ -21,5 +22,19 @@ def run():
pass 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__": if __name__ == "__main__":
cli() cli()

View File

@ -1,2 +1,3 @@
[test] [test]
foo = bar foo = bar
bar = foo

View File

@ -23,4 +23,14 @@ try:
config = validate_with_humanized_errors(_parser_dict, _schema) config = validate_with_humanized_errors(_parser_dict, _schema)
except Error as e: except Error as e:
logger.error('Failed to validate the configuration:\n{}'.format(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')

View File

@ -1,9 +0,0 @@
Developement
============
Update der Manpages
-------------------
.. code-block:: bash
pipenv run sphinx-build -b man doc doc/man

16
doc/development.rst Normal file
View File

@ -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

View File

@ -12,7 +12,7 @@ Welcome to Carom Client's documentation!
api/index api/index
man man
developement development

View File

@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText. .\" 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 .SH NAME
carom-client \- Carom Client Documentation carom-client \- Carom Client Documentation
. .
@ -45,6 +45,19 @@ Options.INDENT 0.0
.B \-v, \-\-verbosity <verbosity> .B \-v, \-\-verbosity <verbosity>
Either CRITICAL, ERROR, WARNING, INFO or DEBUG Either CRITICAL, ERROR, WARNING, INFO or DEBUG
.UNINDENT .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 .SH RUN
.sp .sp
This command runs the carom\-client daemon process. This command runs the carom\-client daemon process.