Added check-config command
This commit is contained in:
		
							
								
								
									
										15
									
								
								carom/cli.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								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() | ||||
|   | ||||
| @@ -1,2 +1,3 @@ | ||||
| [test] | ||||
| foo = bar | ||||
| bar = foo | ||||
| @@ -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') | ||||
|   | ||||
| @@ -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
									
								
							
							
						
						
									
										16
									
								
								doc/development.rst
									
									
									
									
									
										Normal 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 | ||||
| @@ -12,7 +12,7 @@ Welcome to Carom Client's documentation! | ||||
|  | ||||
|    api/index | ||||
|    man | ||||
|    developement | ||||
|    development | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -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 <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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user