diff --git a/bin/cheat b/bin/cheat index 2c15439..a95d592 100755 --- a/bin/cheat +++ b/bin/cheat @@ -46,16 +46,6 @@ import os if __name__ == '__main__': - # validate CHEAT_HIGHLIGHT values if set - colors = [ - 'grey' , 'red' , 'green' , 'yellow' , - 'blue' , 'magenta' , 'cyan' , 'white' , - ] - if ( - os.environ.get('CHEAT_HIGHLIGHT') and - os.environ.get('CHEAT_HIGHLIGHT') not in colors - ): - die("%s %s" %('CHEAT_HIGHLIGHT must be one of:', colors)) # parse the command-line options options = docopt(__doc__, version='cheat 2.3.1') diff --git a/cheat/configuration.py b/cheat/configuration.py index 5062b82..cf3e14e 100644 --- a/cheat/configuration.py +++ b/cheat/configuration.py @@ -28,7 +28,7 @@ class Configuration: merged_config.update(self._read_env_vars_config()) - + self._check_configuration(merged_config) return merged_config @@ -65,6 +65,19 @@ class Configuration: return read_config + def _check_configuration(self, config): + """ Check values in config and warn user or die """ + + # validate CHEAT_HIGHLIGHT values if set + colors = [ + 'grey' , 'red' , 'green' , 'yellow' , + 'blue' , 'magenta' , 'cyan' , 'white' , + ] + if ( + config.get('CHEAT_HIGHLIGHT') and + config.get('CHEAT_HIGHLIGHT') not in colors + ): + Utils.die("%s %s" %('CHEAT_HIGHLIGHT must be one of:', colors)) def _read_env_var(self,current_config,key): if (os.environ.get(key)):