Skip to content

Commit

Permalink
feat: limit divider width to terminal size (#41)
Browse files Browse the repository at this point in the history
* limit divider width to terminal size

* format api.py
  • Loading branch information
jkerola authored Jan 29, 2024
1 parent 1f14ab2 commit 52496c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/jmenu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* API_URL
"""


import requests
from datetime import datetime
from .classes import Restaurant, MenuItem, SKIPPED_ITEMS
Expand Down
11 changes: 9 additions & 2 deletions src/jmenu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import argparse
import time
import sys
from os import get_terminal_size

from importlib.metadata import version, PackageNotFoundError

Expand Down Expand Up @@ -146,9 +147,15 @@ def _print_highlight(items: list[MenuItem], allergens: list[str]):


def _print_header(fetch_date: datetime):
print("-" * 79)
try:
width = get_terminal_size()[0]
if width is None or width > 79:
width = 79
except OSError:
width = 79
print("-" * width)
print("Menu for", fetch_date.strftime("%d.%m"))
print("-" * 79)
print("-" * width)


def get_version() -> str:
Expand Down

0 comments on commit 52496c1

Please sign in to comment.