mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 14:54:00 -06:00
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
import argparse
|
|
from pathlib import Path
|
|
|
|
import xdg
|
|
|
|
from pqcli.roster import Roster
|
|
from pqcli.ui.basic import BasicUserInterface
|
|
from pqcli.ui.urwid import UrwidUserInterface
|
|
|
|
SAVE_PATH = Path(xdg.XDG_CONFIG_HOME) / "pqcli" / "save.dat"
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(prog="pqcli")
|
|
parser.add_argument(
|
|
"--basic", action="store_true", help="Use basic user interface"
|
|
)
|
|
parser.add_argument(
|
|
"--no-config",
|
|
dest="use_config",
|
|
action="store_false",
|
|
help=(
|
|
"Don't load or save configuration files from $XDG_CONFIG_HOME "
|
|
"(player data will still be saved)"
|
|
),
|
|
)
|
|
parser.add_argument(
|
|
"--no-save",
|
|
dest="use_saves",
|
|
action="store_false",
|
|
help=argparse.SUPPRESS,
|
|
)
|
|
parser.add_argument("--cheats", action="store_true", help="???")
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
roster = Roster.load(SAVE_PATH)
|
|
|
|
try:
|
|
if args.basic:
|
|
ui = BasicUserInterface(roster, args)
|
|
else:
|
|
ui = UrwidUserInterface(roster, args)
|
|
|
|
ui.run()
|
|
finally:
|
|
if args.use_saves:
|
|
roster.save()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|