mirror of
https://github.com/cheat/cheat.git
synced 2024-11-22 14:01:36 +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
|
# require the dependencies
|
||||||
from cheat import sheets, sheet
|
from cheat import sheets, sheet
|
||||||
from cheat.utils import colorize
|
from cheat.utils import colorize
|
||||||
|
from cheat.utils import die
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
|
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')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user