mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-04-12 20:13:38 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f112760a74 |
@@ -6,29 +6,7 @@ from typing_extensions import override
|
||||
|
||||
from . import config, console
|
||||
from .__about__ import __version__
|
||||
from .commands import (
|
||||
Fastrestart,
|
||||
Gametype,
|
||||
Hostname,
|
||||
Map,
|
||||
Mapname,
|
||||
Maprestart,
|
||||
Maprotate,
|
||||
Plugins,
|
||||
Status,
|
||||
)
|
||||
|
||||
Subcommands = (
|
||||
Fastrestart
|
||||
| Gametype
|
||||
| Hostname
|
||||
| Map
|
||||
| Mapname
|
||||
| Maprestart
|
||||
| Maprotate
|
||||
| Plugins
|
||||
| Status
|
||||
)
|
||||
from .subcommands import Status, Subcommands
|
||||
|
||||
|
||||
class Q3rconCli(Command):
|
||||
|
||||
@@ -8,14 +8,14 @@ from .maprotate import Maprotate
|
||||
from .plugins import Plugins
|
||||
from .status import Status
|
||||
|
||||
__all__ = [
|
||||
'Status',
|
||||
'Mapname',
|
||||
'Maprotate',
|
||||
'Fastrestart',
|
||||
'Gametype',
|
||||
'Hostname',
|
||||
'Map',
|
||||
'Plugins',
|
||||
'Maprestart',
|
||||
]
|
||||
Subcommands = (
|
||||
Fastrestart
|
||||
| Gametype
|
||||
| Hostname
|
||||
| Map
|
||||
| Mapname
|
||||
| Maprestart
|
||||
| Maprotate
|
||||
| Plugins
|
||||
| Status
|
||||
)
|
||||
@@ -37,7 +37,7 @@ class Gametype(Command):
|
||||
await client.send_command(f'g_gametype {self.new_gametype}')
|
||||
|
||||
if self.force:
|
||||
await Maprestart(self.host, self.port, self.password).configure_and_run()
|
||||
await Maprestart.with_configure(self.host, self.port, self.password).run()
|
||||
|
||||
console.out.print(
|
||||
f'Gametype changed successfully to {self.new_gametype}.', style='green'
|
||||
@@ -12,19 +12,21 @@ class Maprestart(Command):
|
||||
port: int = arg(inherited=True)
|
||||
password: str = arg(inherited=True)
|
||||
|
||||
async def configure_and_run(self):
|
||||
@classmethod
|
||||
def with_configure(cls, host, port, password):
|
||||
"""Configures the command with the appropriate configuration and runs it.
|
||||
|
||||
|
||||
This method is used if we invoke the maprestart command from another command (e.g. gametype),
|
||||
This classmethod is used if we invoke the maprestart command from another command (e.g. gametype),
|
||||
since the pre_run_hook is not called in that case.
|
||||
"""
|
||||
instance = cls(host, port, password)
|
||||
(
|
||||
self.timeout,
|
||||
self.fragment_read_timeout,
|
||||
self.interpret,
|
||||
) = config.get(self.prog().split()[0].lower())
|
||||
await self.run()
|
||||
instance.timeout,
|
||||
instance.fragment_read_timeout,
|
||||
instance.interpret,
|
||||
) = config.get(instance.prog().split()[0].lower())
|
||||
return instance
|
||||
|
||||
@override
|
||||
async def run(self):
|
||||
Reference in New Issue
Block a user