add maprestart command

This commit is contained in:
2026-03-21 10:19:01 +00:00
parent 84702a5360
commit 36e54e89b7
4 changed files with 39 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ from .commands import (
Hostname,
Map,
Mapname,
Maprestart,
Maprotate,
Plugins,
Status,
@@ -16,7 +17,15 @@ from .commands import (
from .console import Console
Subcommands = (
Status | Mapname | Maprotate | Fastrestart | Gametype | Hostname | Map | Plugins
Fastrestart
| Gametype
| Hostname
| Map
| Mapname
| Maprestart
| Maprotate
| Plugins
| Status
)
@@ -54,7 +63,7 @@ class Q3rconCli(Command):
if self.interactive:
await self.run_interactive()
else:
await Status.run(self)
await Status(self.host, self.port, self.password).run()
async def run_interactive(self):
print(

View File

@@ -3,6 +3,7 @@ from .gametype import Gametype
from .hostname import Hostname
from .map import Map
from .mapname import Mapname
from .maprestart import Maprestart
from .maprotate import Maprotate
from .plugins import Plugins
from .status import Status
@@ -16,4 +17,5 @@ __all__ = [
'Hostname',
'Map',
'Plugins',
'Maprestart',
]

View File

@@ -0,0 +1,22 @@
from aioq3rcon import Client
from clypi import Command, Spinner, arg
from typing_extensions import override
from q3rcon_cli.console import Console
class Maprestart(Command):
"""Restarts the current map."""
host: str = arg(inherited=True)
port: int = arg(inherited=True)
password: str = arg(inherited=True)
@override
async def run(self):
async with Spinner('Restarting map...'):
async with Client(
self.host, self.port, self.password, fragment_read_timeout=1
) as client:
if response := await client.send_command('map_restart'):
Console.print_response(response)