Learn cvar and command names from the server for autocomplete

Send cvarlist and cmdlist on connect and merge the answer into the
autocomplete candidates. Number the server menu from 0, keep suggesting
sibling commands while the command name is typed, mask the password in
the startup line, ignore venv/, fix README claims.
This commit is contained in:
pfl
2026-09-16 18:25:48 +02:00
parent db123993c0
commit 3d1dc19d9b
6 changed files with 227 additions and 60 deletions
+42 -31
View File
@@ -40,7 +40,7 @@ qlpycon --host tcp://10.13.12.93:28960 --password secret # connect directly
qlpycon --list # list configured servers
```
Without arguments, qlpycon shows the servers from `[servers]` and connects to the one you select (Up/Down or j/k, Enter or the number key; q quits). If no servers are configured it connects to `[connection] host`.
Without arguments, qlpycon shows the servers from `[servers]` numbered from 0 and connects to the one you select (Up/Down or j/k, Enter or the number key 0-9; q quits). If no servers are configured it connects to `[connection] host`.
**Keys in the console:**
- `Enter`: send the command
@@ -51,12 +51,12 @@ Without arguments, qlpycon shows the servers from `[servers]` and connects to th
- `Ctrl-C` twice: quit
**Options:**
- `--host URI` ZMQ RCON endpoint
- `--password PASS` RCON password (or set `QLPYCON_PASSWORD` env var)
- `--list` list configured servers and exit
- `-v` / `-vv` verbose (INFO) or debug (DEBUG) logging
- `--json FILE` log all JSON events to file
- `--unknown-log FILE` log unparsed events (default: unknown_events.log)
- `--host URI`: ZMQ RCON endpoint
- `--password PASS`: RCON password (or set `QLPYCON_PASSWORD` env var)
- `--list`: list configured servers and exit
- `-v` / `-vv`: verbose (INFO) or debug (DEBUG) logging
- `--json FILE`: log all JSON events to file
- `--unknown-log FILE`: log unparsed events (default: unknown_events.log)
## Features
@@ -64,25 +64,28 @@ Without arguments, qlpycon shows the servers from `[servers]` and connects to th
- Team-aware colorized output with Quake color code support
- Powerup pickup and carrier kill notifications
- Server info panel (map, gametype, scores, players)
- Tab autocomplete for cvars and commands with fuzzy matching
- Argument suggestions for 25+ commands (bot names, maps, gametypes)
- Tab autocomplete for cvars and commands with fuzzy matching; on connect the
server's own `cvarlist` and `cmdlist` output is read so every cvar and
command the server knows is suggested, not only the built-in list
- Argument suggestions for 22 commands (bot names, maps, gametypes)
- Command history (↑/↓)
- Output scrollback (PgUp/PgDn) that survives terminal resizes
## Architecture
```
main.py entry point, arg parsing, signal handling
qlpycon.conf user configuration
main.py - entry point, arg parsing, signal handling
qlpycon.conf - user configuration
lib/
constants.py weapons, teams, colors, limits
settings.py config file loader
state.py game state (server info, players, teams)
network.py ZMQ connections (RCON DEALER, stats SUB)
parser.py JSON event parsing
formatter.py message formatting and colorization
ui.py curses interface (info / output / input panels)
cvars.py cvar/command database and autocomplete
constants.py - weapons, teams, colors, limits
settings.py - config file loader
state.py - game state (server info, players, teams)
network.py - ZMQ connections (RCON DEALER, stats SUB)
parser.py - JSON event parsing
formatter.py - message formatting and colorization
ui.py - curses interface (info / output / input panels)
cvars.py - built-in cvar/command database and autocomplete
namelist.py - learns cvar/command names from the server (cvarlist, cmdlist)
```
## License
@@ -175,7 +178,7 @@ $ addbot Sarge
↑ Shows skill levels (1-5)
$ addbot Sarge 4
red blue free spectator any
red blue free spectator r
↑ Shows team values
$ map
@@ -187,29 +190,35 @@ bloodrun
↑ Fuzzy matches 'blood' → 'bloodrun'
$ g_gametype
0 1 2 3 4 FFA Duel TDM CA CTF
↑ Shows numeric and string gametype values
ffa duel race tdm ca
↑ Shows gametype values (string names first, then the numbers 0-11)
$ callvote
map kick shuffle teamsize
map map_restart nextmap gametype kick
↑ Shows vote types
```
The system knows valid values for **25+ commands** including:
The system knows valid values for **22 commands** including:
- **32 bot names**: Sarge, Ranger, Visor, Xaero, Anarki, etc.
- **40+ maps**: bloodrun, campgrounds, toxicity, aerowalk, etc.
- **12 game types**: FFA, Duel, TDM, CA, CTF, etc. (numeric and string forms)
- **Vote types**: map, kick, shuffle, teamsize, g_gametype, etc.
- **Team values**: red, blue, free, spectator, any
- **38 maps**: bloodrun, campgrounds, toxicity, aerowalk, etc.
- **12 game types**: ffa, duel, tdm, ca, ctf, etc. (string and numeric forms)
- **Vote types**: map, kick, shuffle, teamsize, gametype, etc.
- **Team values**: red, blue, free, spectator (and r, b, f, s)
- **Skill levels**: 1-5 for bots
- **Boolean values**: 0, 1, true, false, enabled, disabled
- **Boolean values**: 0, 1
- **Common settings**: timelimits, fraglimits, sv_fps values, etc.
Arguments with freetext (like player names or custom messages) fall back to showing the signature with highlighting.
## Supported Commands
**76 cvars and commands included:**
Right after connecting, qlpycon sends `cvarlist` and `cmdlist` to the server
and adds every name from the answer to the autocomplete candidates (the
listing itself is hidden from the output). The built-in list below is the
fallback before that answer arrives and the source of signatures and argument
values.
**Built-in cvars and commands:**
### Commands with Signatures
@@ -275,7 +284,9 @@ autocomplete('stat')
### Add Your Own Cvars
Edit `cvars.py` and add to the appropriate list:
Names the server reports via `cvarlist`/`cmdlist` are picked up automatically.
To add a signature or argument values, or a name the server does not report,
edit `cvars.py` and add to the appropriate list:
```python
# Custom cvars