mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-03-23 18:29:18 +00:00
add maprestart command
This commit is contained in:
parent
84702a5360
commit
36e54e89b7
@ -60,14 +60,15 @@ export Q3RCON_CLI_PASSWORD="<rcon password>"
|
||||
Usage: q3rcon-cli [OPTIONS] COMMAND
|
||||
|
||||
┏━ Subcommands ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ status Prints the status of the server ┃
|
||||
┃ mapname Prints the current map name of the server ┃
|
||||
┃ maprotate Rotates the map to the next one in the map rotation list ┃
|
||||
┃ fastrestart Executes a fast restart of the server ┃
|
||||
┃ gametype Get or set the current gametype of the server ┃
|
||||
┃ hostname Get or set the current hostname of the server ┃
|
||||
┃ map Get the current map or change to a new one ┃
|
||||
┃ mapname Prints the current map name of the server ┃
|
||||
┃ maprestart Restarts the current map ┃
|
||||
┃ maprotate Rotates the map to the next one in the map rotation list ┃
|
||||
┃ plugins Prints the currently loaded plugins of the server ┃
|
||||
┃ status Prints the status of the server ┃
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
┏━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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',
|
||||
]
|
||||
|
||||
22
src/q3rcon_cli/commands/maprestart.py
Normal file
22
src/q3rcon_cli/commands/maprestart.py
Normal 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)
|
||||
Loading…
x
Reference in New Issue
Block a user