diff --git a/toot/commands.py b/toot/commands.py index 7853179..69c9c58 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -417,4 +417,4 @@ def notifications(app, user, args): def tui(app, user, args): from .tui.app import TUI - TUI.create(app, user).run() + TUI.create(app, user, args).run() diff --git a/toot/console.py b/toot/console.py index 38e0656..f29856c 100644 --- a/toot/console.py +++ b/toot/console.py @@ -254,7 +254,13 @@ TUI_COMMANDS = [ Command( name="tui", description="Launches the toot terminal user interface", - arguments=[], + arguments=[ + (["--relative-datetimes"], { + "action": "store_true", + "default": False, + "help": "Show relative datetimes in status list.", + }), + ], require_auth=True, ), ] diff --git a/toot/tui/app.py b/toot/tui/app.py index 7429a73..16c284f 100644 --- a/toot/tui/app.py +++ b/toot/tui/app.py @@ -73,10 +73,10 @@ class TUI(urwid.Frame): """Main TUI frame.""" @classmethod - def create(cls, app, user): + def create(cls, app, user, args): """Factory method, sets up TUI and an event loop.""" - tui = cls(app, user) + tui = cls(app, user, args) loop = urwid.MainLoop( tui, palette=PALETTE, @@ -87,9 +87,10 @@ class TUI(urwid.Frame): return tui - def __init__(self, app, user): + def __init__(self, app, user, args): self.app = app self.user = user + self.args = args self.config = config.load_config() self.loop = None # set in `create` diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 14e0342..d4b9b74 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -1,4 +1,5 @@ import logging +import sys import urwid import webbrowser @@ -421,7 +422,15 @@ class StatusDetails(urwid.Pile): class StatusListItem(SelectableColumns): def __init__(self, status): edited = status.data["edited_at"] - created_at = time_ago(status.created_at).ljust(3, " ") + + # TODO: hacky implementation to avoid creating conflicts for existing + # pull reuqests, refactor when merged. + created_at = ( + time_ago(status.created_at).ljust(3, " ") + if "--relative-datetimes" in sys.argv + else status.created_at.strftime("%Y-%m-%d %H:%M") + ) + edited_flag = "*" if edited else " " favourited = ("yellow", "★") if status.original.favourited else " " reblogged = ("yellow", "♺") if status.original.reblogged else " "