diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5c15d5..fcc4bcd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,7 +73,7 @@ jobs: mytimer --minute=0 --second=3 --countdown --h-shift=10 --v-shift=12 --hide-second --vertical - name: Run12 run: | - mytimer --minute=0 --second=3 --countdown --h-shift=10 --v-shift=12 --hide-second --vertical --color="red" + mytimer --minute=0 --second=3 --countdown --h-shift=10 --v-shift=12 --hide-second --vertical --color="red" --bg-color="blue" - name: Run13 run: | mytimer --info diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d2d961..8547801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added - `--color` argument +- `--bg-color` argument ### Changed - `load_program_params` function modified - `pomodoro_timer` function modified diff --git a/README.md b/README.md index a9b5745..6574e4c 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,16 @@ mytimer --minute=7 --second=30 --message="Test message" mytimer --minute=7 --second=30 --color="red" ``` +### Background Color + +ℹ️ Valid choices: [`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`] + +ℹ️ The default background color is `black` + +```console +mytimer --minute=7 --second=30 --bg-color="blue" +``` + ## Screen Record
diff --git a/mytimer/__main__.py b/mytimer/__main__.py index 9cc3ef4..7859528 100644 --- a/mytimer/__main__.py +++ b/mytimer/__main__.py @@ -22,7 +22,12 @@ def main() -> None: choices=FACES_LIST) parser.add_argument( '--color', - help='color', + help='text color', + type=str.lower, + choices=COLORS_LIST) + parser.add_argument( + '--bg-color', + help='background color', type=str.lower, choices=COLORS_LIST) parser.add_argument( diff --git a/mytimer/functions.py b/mytimer/functions.py index fea8a25..e3386bd 100644 --- a/mytimer/functions.py +++ b/mytimer/functions.py @@ -9,7 +9,7 @@ import random import argparse from nava import play -from colorama import Fore +from colorama import Fore, Back from mytimer.params import INPUT_ERROR_MESSAGE, SOUND_ERROR_MESSAGE from mytimer.params import INPUT_EXAMPLE, TIME_ELEMENTS, MESSAGE_TEMPLATE from mytimer.params import FACES_MAP, PROGRAMS_MAP, BREAKS_MAP, TONES_MAP @@ -242,6 +242,17 @@ def set_color(color: str) -> None: print(getattr(Fore, color, ""), end="") +def set_bg_color(bg_color: str) -> None: + """ + Set background color. + + :param bg_color: background color name + """ + if bg_color: + bg_color = bg_color.strip().upper() + print(getattr(Back, bg_color, ""), end="") + + def get_tone(index: int) -> str: """ Return tone file name. @@ -585,6 +596,7 @@ def run_timer(args: argparse.Namespace) -> None: :param args: input arguments """ set_color(color=args.color) + set_bg_color(bg_color=args.bg_color) params = load_params(args) timer_function, params = select_timer_function(args, params) if args.set_on: