diff --git a/.hues.yml b/.hues.yml new file mode 100644 index 0000000..062e892 --- /dev/null +++ b/.hues.yml @@ -0,0 +1,9 @@ +labels: + info: INFO + warn: WARN + error: ERR + success: S +hues: + time: blue +options: + theme: powerline diff --git a/docs/index.md b/docs/index.md index e142413..2a485c2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,11 +1,6 @@ # Hues +This is the 90s and your terminal can display _16_ glorious colors. Your Python scripts deserve the some color love. `Hues` makes printing to console in color easy. Just grab the package from `PIP`, and your monochromatic days will be a thing of past! -This is the 90s and your terminal can display _16_ glorious colors. -Your Python scripts deserve the some color love. `Hues` makes printing -to console in color easy. - -Just grab the package from `PIP`, and your monochromatic days will be a -thing of past! ## Quickstart @@ -15,13 +10,25 @@ Go, grab the latest version from PIP. Run: pip install hues ``` -Then, in your scripts, do this: +Then, in your scripts you can do this: ```python ->>> from hues import hue ->>> print(hue('unicorns!').bright_cyan.bold) +import hues + +hues.info('Destroying the universe') + +try: + destroyinator() +except IncomingPerryThePlatipus: + hues.error('Curse you Perry the Platipus!') +else: + hues.success('Destroyed the universe.') ``` + + +## Configuration +[TODO] _whoa!_ @@ -41,9 +48,5 @@ Each `hue` string is self closing, so you can't accidentally color your whole te All 16 glorious ANSI colors are available for both background and foreground. Assorted text styles such as **`bold`**, _`italics`_ and `underline` are also available. Too many colors? Worry not fam, go to town with `reset` attribute. -## Todo -- [ ] Expand this readme. -- [ ] Add screenshots! -- [ ] Unicorns required. > Back in my days, we didn't even have colors! diff --git a/example.py b/example.py new file mode 100644 index 0000000..22a410f --- /dev/null +++ b/example.py @@ -0,0 +1,30 @@ +import hues +import random +import time + + +class ThisPlanetIsProtected(Exception): + pass + + +def destroy_planet(planet): + if planet == 'Earth': + raise ThisPlanetIsProtected + return random.randint(0, 100) < 42 + +if __name__ == '__main__': + hues.info('Destroying the planets. Please wait.') + + for planet in ('Murcury', 'Venus', 'Earth', 'Mars', 'Uranus',): + try: + success = destroy_planet(planet) + except ThisPlanetIsProtected: + hues.warn('The Doctor saved', planet) + else: + if success: + hues.success('Destroyed', planet) + else: + hues.error('Could not destroy', planet) + time.sleep(.5) + + hues.info('So long, and thanks for all the fish.')