mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-04-12 20:13:38 +00:00
rename commands submodule to subcommands.
add Maprestart.with_configure()
This commit is contained in:
@@ -6,29 +6,7 @@ from typing_extensions import override
|
|||||||
|
|
||||||
from . import config, console
|
from . import config, console
|
||||||
from .__about__ import __version__
|
from .__about__ import __version__
|
||||||
from .commands import (
|
from .subcommands import Status, Subcommands
|
||||||
Fastrestart,
|
|
||||||
Gametype,
|
|
||||||
Hostname,
|
|
||||||
Map,
|
|
||||||
Mapname,
|
|
||||||
Maprestart,
|
|
||||||
Maprotate,
|
|
||||||
Plugins,
|
|
||||||
Status,
|
|
||||||
)
|
|
||||||
|
|
||||||
Subcommands = (
|
|
||||||
Fastrestart
|
|
||||||
| Gametype
|
|
||||||
| Hostname
|
|
||||||
| Map
|
|
||||||
| Mapname
|
|
||||||
| Maprestart
|
|
||||||
| Maprotate
|
|
||||||
| Plugins
|
|
||||||
| Status
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Q3rconCli(Command):
|
class Q3rconCli(Command):
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ from .maprotate import Maprotate
|
|||||||
from .plugins import Plugins
|
from .plugins import Plugins
|
||||||
from .status import Status
|
from .status import Status
|
||||||
|
|
||||||
__all__ = [
|
Subcommands = (
|
||||||
'Status',
|
Fastrestart
|
||||||
'Mapname',
|
| Gametype
|
||||||
'Maprotate',
|
| Hostname
|
||||||
'Fastrestart',
|
| Map
|
||||||
'Gametype',
|
| Mapname
|
||||||
'Hostname',
|
| Maprestart
|
||||||
'Map',
|
| Maprotate
|
||||||
'Plugins',
|
| Plugins
|
||||||
'Maprestart',
|
| Status
|
||||||
]
|
)
|
||||||
@@ -37,7 +37,7 @@ class Gametype(Command):
|
|||||||
await client.send_command(f'g_gametype {self.new_gametype}')
|
await client.send_command(f'g_gametype {self.new_gametype}')
|
||||||
|
|
||||||
if self.force:
|
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(
|
console.out.print(
|
||||||
f'Gametype changed successfully to {self.new_gametype}.', style='green'
|
f'Gametype changed successfully to {self.new_gametype}.', style='green'
|
||||||
@@ -12,19 +12,21 @@ class Maprestart(Command):
|
|||||||
port: int = arg(inherited=True)
|
port: int = arg(inherited=True)
|
||||||
password: str = 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.
|
"""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.
|
since the pre_run_hook is not called in that case.
|
||||||
"""
|
"""
|
||||||
|
instance = cls(host, port, password)
|
||||||
(
|
(
|
||||||
self.timeout,
|
instance.timeout,
|
||||||
self.fragment_read_timeout,
|
instance.fragment_read_timeout,
|
||||||
self.interpret,
|
instance.interpret,
|
||||||
) = config.get(self.prog().split()[0].lower())
|
) = config.get(instance.prog().split()[0].lower())
|
||||||
await self.run()
|
return instance
|
||||||
|
|
||||||
@override
|
@override
|
||||||
async def run(self):
|
async def run(self):
|
||||||
Reference in New Issue
Block a user