Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<div align="center">
Expand Down
7 changes: 6 additions & 1 deletion mytimer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 13 additions & 1 deletion mytimer/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down