mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-07-29 16:54:29 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da3304cd3a | |||
| f112760a74 |
@@ -80,7 +80,7 @@ Usage: q3rcon-cli [OPTIONS] COMMAND
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
┏━ Connection options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ -h, --host <HOST> The host to connect to ┃
|
||||
┃ -H, --host <HOST> The host to connect to ┃
|
||||
┃ -p, --port <PORT> The port to connect to ┃
|
||||
┃ -P, --password <PASSWORD> The password for authentication ┃
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
@@ -20,7 +20,7 @@ classifiers = [
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
]
|
||||
dependencies = ["aio-q3-rcon>=1.0.1", "clypi>=1.8.2"]
|
||||
dependencies = ["aio-q3-rcon>=1.0.1", "clypi>=1.9.1"]
|
||||
|
||||
[project.scripts]
|
||||
q3rcon-cli = "q3rcon_cli.cli:main"
|
||||
@@ -34,7 +34,7 @@ Source = "https://github.com/onyx-and-iris/q3rcon-cli"
|
||||
path = "src/q3rcon_cli/__about__.py"
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
workspace.members = [{ path = "../aio-q3-rcon" }]
|
||||
workspace.members = [{ path = "../aio-q3-rcon" }] #, { path = "../clypi" }]
|
||||
|
||||
[tool.hatch.envs.types]
|
||||
extra-dependencies = ["mypy>=1.0.0"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2026-present onyx-and-iris <code@onyxandiris.online>
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
__version__ = '0.4.0'
|
||||
__version__ = '0.4.1'
|
||||
|
||||
@@ -6,36 +6,14 @@ 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):
|
||||
subcommand: Subcommands | None = None
|
||||
host: str = arg(
|
||||
'localhost',
|
||||
short='h',
|
||||
short='H',
|
||||
help='The host to connect to',
|
||||
env='Q3RCON_CLI_HOST',
|
||||
group='Connection',
|
||||
|
||||
@@ -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