Skip to content

Commit

Permalink
feat: add "dumdum appdirs" command
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Mar 11, 2024
1 parent 59b8bd0 commit 0c7c7ba
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/dumdum/client/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Start the client interface for connecting to dumdum servers."""

from __future__ import annotations

import argparse
Expand All @@ -25,12 +26,31 @@ def main():
default=0,
help="Increase logging verbosity",
)
parser.set_defaults(mode="gui")

commands = parser.add_subparsers()

appdirs = commands.add_parser(
"appdirs",
description="Show data directories used by dumdum.",
)
appdirs.set_defaults(mode="appdirs")

args = parser.parse_args()
verbose: int = args.verbose
mode: str = args.mode

configure_logging(verbose)

if mode == "gui":
run_gui()
elif mode == "appdirs":
show_appdirs()
else:
raise RuntimeError(f"Unknown mode {mode!r}")


def run_gui() -> None:
with EventThread() as event_thread:
app = TkApp(
event_thread=event_thread,
Expand All @@ -40,6 +60,12 @@ def main():
app.mainloop()


def show_appdirs() -> None:
from dumdum.appdirs import APP_DIRS

print("user_data_path =", APP_DIRS.user_data_path)


@contextlib.contextmanager
def store_factory() -> Iterator[ClientStore]:
with ClientStore.from_appdirs() as store, store.conn.transaction():
Expand Down

0 comments on commit 0c7c7ba

Please sign in to comment.