From 7682f4080eaf0982d1175ebf380fa20934a49166 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 19 Feb 2026 22:29:15 +0000 Subject: [PATCH] first commit --- .github/workflows/publish.yml | 39 +++++++ .github/workflows/ruff.yml | 19 +++ .gitignore | 213 ++++++++++++++++++++++++++++++++++ LICENSE.txt | 9 ++ README.md | 58 +++++++++ img/tui.png | Bin 0 -> 16595 bytes pyproject.toml | 57 +++++++++ ruff.toml | 77 ++++++++++++ src/q3rcon_tui/__about__.py | 4 + src/q3rcon_tui/__init__.py | 3 + src/q3rcon_tui/rcon_tui.tcss | 84 ++++++++++++++ src/q3rcon_tui/tui.py | 114 ++++++++++++++++++ tests/__init__.py | 3 + 13 files changed, 680 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/ruff.yml create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 img/tui.png create mode 100644 pyproject.toml create mode 100644 ruff.toml create mode 100644 src/q3rcon_tui/__about__.py create mode 100644 src/q3rcon_tui/__init__.py create mode 100644 src/q3rcon_tui/rcon_tui.tcss create mode 100644 src/q3rcon_tui/tui.py create mode 100644 tests/__init__.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5888db6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish to PyPI + +on: + release: + types: [published] + push: + tags: + - 'v*.*.*' + +jobs: + deploy: + runs-on: ubuntu-latest + + environment: pypi + permissions: + # This permission is needed for private repositories. + contents: read + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + steps: + - uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch + + - name: Build package + run: hatch build + + - name: Publish on PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..72ff650 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,19 @@ +name: Ruff + +on: + push: + branches: [main] + + pull_request: + branches: [main] + + workflow_dispatch: + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: astral-sh/ruff-action@v3 + with: + args: 'format --check --diff' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d7f108 --- /dev/null +++ b/.gitignore @@ -0,0 +1,213 @@ +# Generated by ignr: github.com/onyx-and-iris/ignr + +## Python ## +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[codz] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py.cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock +#poetry.toml + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. +# https://pdm-project.org/en/latest/usage/project/#working-with-version-control +#pdm.lock +#pdm.toml +.pdm-python +.pdm-build/ + +# pixi +# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. +#pixi.lock +# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one +# in the .venv directory. It is recommended not to include this directory in version control. +.pixi + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.envrc +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +.hatch + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# Abstra +# Abstra is an AI-powered process automation framework. +# Ignore directories containing user credentials, local state, and settings. +# Learn more at https://abstra.io/docs +.abstra/ + +# Visual Studio Code +# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore +# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +# and can be added to the global gitignore or merged into this file. However, if you prefer, +# you could uncomment the following to ignore the entire vscode folder +# .vscode/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc + +# Cursor +# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to +# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data +# refer to https://docs.cursor.com/context/ignore-files +.cursorignore +.cursorindexingignore + +# Marimo +marimo/_static/ +marimo/_lsp/ +__marimo__/ + +# End of ignr diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..7a3e852 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2026-present onyx-and-iris + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d337d8 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# q3rcon tui + +[![PyPI - Version](https://img.shields.io/pypi/v/q3rcon-tui.svg)](https://pypi.org/project/q3rcon-tui) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/q3rcon-tui.svg)](https://pypi.org/project/q3rcon-tui) + +----- + +![img](./img/tui.png) + +## Table of Contents + +- [Installation](#installation) +- [License](#license) + +## Installation + +*with uv* + +```console +uv tool install q3rcon-tui +``` + +*with pipx* + +```console +pipx install q3rcon-tui +``` + +The TUI should now be discoverable as q3rcon-tui. + +## Configuration + +#### Flags + +Pass `--host`, `--port` and `--password` as flags: + +```console +q3rcon-tui --host=localhost --port=28960 --password=rconpassword +``` + +#### Environment Variables + +Store and load from dotenv files located at: +- .env in the cwd +- user home directory / .config / rcon-tui / config.env + +example .env: + +```bash +Q3RCON_TUI_HOST=localhost +Q3RCON_TUI_PORT=28960 +Q3RCON_TUI_PASSWORD=rconpassword +Q3RCON_TUI_REFRESH_OUTPUT=true +``` + +## License + +`q3rcon-tui` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. diff --git a/img/tui.png b/img/tui.png new file mode 100644 index 0000000000000000000000000000000000000000..60194f10848ce21f4979bd80e815f45598f49bc4 GIT binary patch literal 16595 zcmeHucUV)|+HV|YbZju76s0M4>L4N@1W-@}6h;vNLy;P(q4y9RM~QS%nzRv+Dv7kv zgVHici6{_yG?dT+hTf9g6=2SF&Nt`W`ObH~d+&3f`v>goz1QCBec$!=_1lks($m_% z=kOi~1hQZIs^(1yg|M4M}Ni1wN2>n<@=qCYW&e%-D6y zHEX(gVANt{P2MInTn#^|6UOswOp9ax_ia&GRa4B1M%PIiAI+q`I~Qny^}vTPh7#duR2gub#4`nMn8Z4S=O#~TtKPlX@bAbTw*+{e^$C8QS(^2;dr^j-);BdH*YM>&g@P&ix%d=7SAzb|H z?iHpZS=W=2WTrK*C;WK6T?uX_q&gsCW~P;%pYQQrGziEQqH$e1J`B*8gTX|8t`8x! zrzl(d=)XVA{lxKJLQ>RkgoO!%^sFp#P9a~|>2JUT$)$ODc~&F8J#kz4^0}wlZ@%M> zrs~OS0{rswhJ`4W%jfUGAlKVdGc%DKyEq%r+{dga4Uf6GZx|XF9H1u4$$~d2D~o_Z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cbo%wf1l)mBl^opKu0X;-iU3X>AE_=FSZL&X< z@$k@5gKWHnOEq1t&~u_zqPr;yD-#)p?x`$Q;uPvRASH!;)~OY#vX<5r8L81&?^6^) zhp3+b3IVVk$(ro<7CDk&^Z^fYgeddNEcjqe?n&N-kUlh#w1YjaJD z@HVCe@{|3pzCN)v#bigNSQN!U%#07tWYX~44ushO# z?x6QMs)bQg*IiVW2YiN0NkO-lWCn#Ubc%Gy3BGi7?{r^&Z@;?p#Y-Ag>JS-Xo9KrbHINFFg zktQY*Ct6z}3u}h-WW?`=Jo)v^nUh?`7syPnwNkDY=fp7$Pc_NE2aNn4HM3!#1CO(vt0R*lLz%0Zl~&UF9&##; z9Z>X&%>Wtz=QRa1h%(*F_J`9yK=jVC!^FNFMCcdwjSU3rJe%A8?t(Bd7#;#~S%)~?L#ll*R(#d3Mz z<8UGCM_XcB2*-pfdXB&E2+qXiUFc_jT;_?*e{ade8ZcjK!Y^~J;BF-ZFzYS)NWKdxIbaK-i3WzCXO+T-W-!mi#O=*hRG4~tD*HCYo1Ar$DWNK5#=2rtXH33{(wLMYg49?TDk%__Fn|-IH zr7y~UDlzY*&%!USGVG&jYxwUr=8n>T7i#x^F}->Z%P<{7rq-YZpSI7j^5rwySRiy0a~`PA2AySKHe3jjqkq7L>ZG4BCMh46gIosm-RF; Jm+t=jKLE)aF#`Yq literal 0 HcmV?d00001 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8ab3c03 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,57 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "q3rcon-tui" +dynamic = ["version"] +description = '' +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +keywords = [] +authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + "aio-q3-rcon>=1.0.0", + "loguru>=0.7.3", + "pydantic-settings>=2.13.1", + "textual>=8.0.0", +] + +[project.scripts] +q3rcon-tui = "q3rcon_tui.tui:main" + +[project.urls] +Documentation = "https://github.com/onyx-and-iris/q3rcon-tui#readme" +Issues = "https://github.com/onyx-and-iris/q3rcon-tui/issues" +Source = "https://github.com/onyx-and-iris/q3rcon-tui" + +[tool.hatch.version] +path = "src/q3rcon_tui/__about__.py" + +[tool.hatch.envs.types] +extra-dependencies = ["mypy>=1.0.0"] +[tool.hatch.envs.types.scripts] +check = "mypy --install-types --non-interactive {args:src/q3rcon_tui tests}" + +[tool.coverage.run] +source_pkgs = ["q3rcon_tui", "tests"] +branch = true +parallel = true +omit = ["src/q3rcon_tui/__about__.py"] + +[tool.coverage.paths] +q3rcon_tui = ["src/q3rcon_tui", "*/q3rcon-tui/src/q3rcon_tui"] +tests = ["tests", "*/q3rcon-tui/tests"] + +[tool.coverage.report] +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..bf5472e --- /dev/null +++ b/ruff.toml @@ -0,0 +1,77 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.9 +target-version = "py39" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Unlike Black, use single quotes for strings. +quote-style = "single" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" diff --git a/src/q3rcon_tui/__about__.py b/src/q3rcon_tui/__about__.py new file mode 100644 index 0000000..6daf468 --- /dev/null +++ b/src/q3rcon_tui/__about__.py @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2026-present onyx-and-iris +# +# SPDX-License-Identifier: MIT +__version__ = '0.1.0' diff --git a/src/q3rcon_tui/__init__.py b/src/q3rcon_tui/__init__.py new file mode 100644 index 0000000..c593fbf --- /dev/null +++ b/src/q3rcon_tui/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2026-present onyx-and-iris +# +# SPDX-License-Identifier: MIT diff --git a/src/q3rcon_tui/rcon_tui.tcss b/src/q3rcon_tui/rcon_tui.tcss new file mode 100644 index 0000000..9e245f7 --- /dev/null +++ b/src/q3rcon_tui/rcon_tui.tcss @@ -0,0 +1,84 @@ +#dialog { + height: 30; + margin: 4 8; + background: #1e1e2f; + color: #e2e8f0; + border: heavy #3b4252; + border-title-color: #88c0d0; + border-title-style: bold; + padding: 1 3; + grid-size: 2 3; + grid-gutter: 1 2; + grid-rows: auto 1fr auto; + align: center middle; +} + +#command { + column-span: 2; + height: auto; + width: 1fr; + content-align: center middle; + background: #2e3440; + border: solid #4c566a; + border-title-color: #81a1c1; + padding: 0 1; + margin: 0 1; +} + +#command:focus { + border: solid #88c0d0; + background: #3b4252; +} + +#response { + column-span: 2; + height: 1fr; + background: #2e3440; + border: solid #4c566a; + border-title-color: #a3be8c; + padding: 1; + margin: 0 1; + scrollbar-background: #3b4252; + scrollbar-color: #5e81ac; +} + +Button { + width: 100%; + height: 3; + margin: 0 1; + background: #5e81ac; + color: #eceff4; + border: none; + text-style: bold; +} + +Button:hover { + background: #81a1c1; + text-style: bold; +} + +Button.error { + background: #bf616a; +} + +Button.error:hover { + background: #d08770; +} + +#quit { + background: #bf616a; + border: solid #bf616a; +} + +#quit:hover { + background: #d08770; + border: solid #ebcb8b; +} + +#send { + background: #a3be8c; +} + +#send:hover { + background: #8fbcbb; +} \ No newline at end of file diff --git a/src/q3rcon_tui/tui.py b/src/q3rcon_tui/tui.py new file mode 100644 index 0000000..9a3656e --- /dev/null +++ b/src/q3rcon_tui/tui.py @@ -0,0 +1,114 @@ +import re +from pathlib import Path +from typing import Annotated, Type + +from aioq3rcon import Client +from loguru import logger +from pydantic import AfterValidator, BeforeValidator +from pydantic_settings import BaseSettings, CliSettingsSource, SettingsConfigDict +from textual.app import App, ComposeResult +from textual.containers import Grid +from textual.widgets import Button, Input, RichLog + +from .__about__ import __version__ as version + + +def is_valid_password(password: str) -> str | None: + if len(password) < 8: + raise ValueError('Password must be at least 8 characters long') + return password + + +def version_callback(value: bool) -> bool | None: + if value: + print(f'q3rcon-tui version: {version}') + raise SystemExit(0) + return False + + +class Settings(BaseSettings): + host: str = 'localhost' + port: int = 28960 + password: Annotated[str, AfterValidator(is_valid_password)] = '' + refresh_output: bool = False + version: Annotated[bool, BeforeValidator(version_callback)] = False + + model_config = SettingsConfigDict( + env_file=( + '.env', + Path.home() / '.config' / 'rcon-tui' / 'config.env', + ), + env_file_encoding='utf-8', + env_prefix='Q3RCON_TUI_', + cli_prefix='', + cli_parse_args=True, + cli_implicit_flags=True, + ) + + @classmethod + def settings_customise_sources( + cls, + settings_cls: Type[BaseSettings], + init_settings: ..., + env_settings: ..., + dotenv_settings: ..., + file_secret_settings: ..., + ) -> tuple: + return ( + CliSettingsSource(settings_cls), + env_settings, + dotenv_settings, + init_settings, + ) + + +try: + settings = Settings() +except ValueError as e: + logger.error(e) + raise SystemExit(1) + + +class RconApp(App): + RE_COLOR_CODES = re.compile(r'\^[0-9]') + CSS_PATH = 'rcon_tui.tcss' + + def compose(self) -> ComposeResult: + yield Grid( + Input('status', placeholder='Enter a rcon command', id='command'), + RichLog(id='response'), + Button('Send', variant='error', id='send'), + Button('Quit', variant='primary', id='quit'), + id='dialog', + ) + + async def on_key(self, event) -> None: + if event.key == 'enter': + if self.query_one('#command', Input).has_focus: + self.query_one('#send', Button).press() + + async def on_button_pressed(self, event: Button.Pressed) -> None: + if event.button.id == 'quit': + self.app.exit() + + if settings.refresh_output: + self.query_one('#response', RichLog).clear() + + async with Client(settings.host, settings.port, settings.password) as client: + response = await client.send_command( + self.query_one('#command', Input).value + ) + self.query_one('#response', RichLog).write( + self.remove_color_codes(response.removeprefix('print\n')) + ) + + self.query_one('#command', Input).value = '' + + @staticmethod + def remove_color_codes(s: str) -> str: + return RconApp.RE_COLOR_CODES.sub('', s) + + +def main(): + app = RconApp() + app.run() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..c593fbf --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2026-present onyx-and-iris +# +# SPDX-License-Identifier: MIT