init
This commit is contained in:
commit
70332388e8
17 changed files with 242 additions and 0 deletions
42
cave_survival/cli/__init__.py
Normal file
42
cave_survival/cli/__init__.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
import debugpy
|
||||
import typer
|
||||
|
||||
from cave_survival.console import console
|
||||
from cave_survival.run import run
|
||||
|
||||
from ..__about__ import __version__, name
|
||||
|
||||
|
||||
def version_callback(value: bool) -> None:
|
||||
if value:
|
||||
console.print(f"{__version__}")
|
||||
raise typer.Exit()
|
||||
|
||||
|
||||
app = typer.Typer(
|
||||
name=name,
|
||||
help="A cave survival game",
|
||||
)
|
||||
|
||||
|
||||
@app.callback(invoke_without_command=True)
|
||||
def main(
|
||||
version: bool = typer.Option(
|
||||
False,
|
||||
"--version",
|
||||
callback=version_callback, # is_eager=True
|
||||
),
|
||||
debug: bool = typer.Option(None, "--debug", help="start with debug mode running"),
|
||||
) -> None:
|
||||
if debug:
|
||||
print("debugging")
|
||||
debugpy.listen(("localhost", 5678))
|
||||
print("waiting...")
|
||||
debugpy.wait_for_client()
|
||||
|
||||
run()
|
||||
# Do other global stuff, handle other global options here
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue