mirror of
https://github.com/cheat/cheat.git
synced 2024-12-22 12:45:06 +01:00
Implemented validation on CHEAT_HIGHLIGHT
Implemnted an assertion that `CHEAT_HIGHLIGHT` (if set) contains a value that is acceptible to `termcolors`. This happens only once, upon the invokation of `__main__`. If the assertion fails, `cheat` terminates with an exit code of `1`.
This commit is contained in:
parent
730c488854
commit
28a2902e20
14
bin/cheat
14
bin/cheat
@ -37,10 +37,24 @@ Examples:
|
||||
# require the dependencies
|
||||
from cheat import sheets, sheet
|
||||
from cheat.utils import colorize
|
||||
from cheat.utils import die
|
||||
from docopt import docopt
|
||||
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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user