mirror of
https://github.com/cheat/cheat.git
synced 2024-11-25 15:31:36 +01:00
Move validation of CHEAT_HIGHLIGHT value to Configuration class
Method _check_configuration should be used for validating all bad values from now on
This commit is contained in:
parent
5eec6bf040
commit
a2e028fd19
10
bin/cheat
10
bin/cheat
@ -46,16 +46,6 @@ import os
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
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
|
# parse the command-line options
|
||||||
options = docopt(__doc__, version='cheat 2.3.1')
|
options = docopt(__doc__, version='cheat 2.3.1')
|
||||||
|
@ -28,7 +28,7 @@ class Configuration:
|
|||||||
|
|
||||||
merged_config.update(self._read_env_vars_config())
|
merged_config.update(self._read_env_vars_config())
|
||||||
|
|
||||||
|
self._check_configuration(merged_config)
|
||||||
|
|
||||||
return merged_config
|
return merged_config
|
||||||
|
|
||||||
@ -65,6 +65,19 @@ class Configuration:
|
|||||||
|
|
||||||
return read_config
|
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):
|
def _read_env_var(self,current_config,key):
|
||||||
if (os.environ.get(key)):
|
if (os.environ.get(key)):
|
||||||
|
Loading…
Reference in New Issue
Block a user