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
|
Usage: q3rcon-cli [OPTIONS] COMMAND
|
||||||
|
|
||||||
┏━ Subcommands ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
┏━ 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 ┃
|
┃ fastrestart Executes a fast restart of the server ┃
|
||||||
┃ gametype Get or set the current gametype of the server ┃
|
┃ gametype Get or set the current gametype of the server ┃
|
||||||
┃ hostname Get or set the current hostname of the server ┃
|
┃ hostname Get or set the current hostname of the server ┃
|
||||||
┃ map Get the current map or change to a new one ┃
|
┃ 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 ┃
|
┃ plugins Prints the currently loaded plugins of the server ┃
|
||||||
|
┃ status Prints the status of the server ┃
|
||||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||||
|
|
||||||
┏━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
┏━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from .commands import (
|
|||||||
Hostname,
|
Hostname,
|
||||||
Map,
|
Map,
|
||||||
Mapname,
|
Mapname,
|
||||||
|
Maprestart,
|
||||||
Maprotate,
|
Maprotate,
|
||||||
Plugins,
|
Plugins,
|
||||||
Status,
|
Status,
|
||||||
@ -16,7 +17,15 @@ from .commands import (
|
|||||||
from .console import Console
|
from .console import Console
|
||||||
|
|
||||||
Subcommands = (
|
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:
|
if self.interactive:
|
||||||
await self.run_interactive()
|
await self.run_interactive()
|
||||||
else:
|
else:
|
||||||
await Status.run(self)
|
await Status(self.host, self.port, self.password).run()
|
||||||
|
|
||||||
async def run_interactive(self):
|
async def run_interactive(self):
|
||||||
print(
|
print(
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from .gametype import Gametype
|
|||||||
from .hostname import Hostname
|
from .hostname import Hostname
|
||||||
from .map import Map
|
from .map import Map
|
||||||
from .mapname import Mapname
|
from .mapname import Mapname
|
||||||
|
from .maprestart import Maprestart
|
||||||
from .maprotate import Maprotate
|
from .maprotate import Maprotate
|
||||||
from .plugins import Plugins
|
from .plugins import Plugins
|
||||||
from .status import Status
|
from .status import Status
|
||||||
@ -16,4 +17,5 @@ __all__ = [
|
|||||||
'Hostname',
|
'Hostname',
|
||||||
'Map',
|
'Map',
|
||||||
'Plugins',
|
'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