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