mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-04-13 04:23:38 +00:00
add Config class for configuring timings for both interactive and direct modes.
pre_run_hook added, it runs before all subcommands. gametype command now calls maprestart command directly if the -f flag is passed.
This commit is contained in:
35
src/q3rcon_cli/config.py
Normal file
35
src/q3rcon_cli/config.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from collections import UserDict
|
||||
|
||||
|
||||
class Config(UserDict):
|
||||
DEFAULT_TIMEOUT: int = 2
|
||||
DEFAULT_FRAGMENT_READ_TIMEOUT: float = 0.25
|
||||
|
||||
def __init__(self):
|
||||
self.data = {
|
||||
'status': (2, 0.25, False),
|
||||
'fast_restart': (3, 1, True),
|
||||
'map_restart': (3, 1, True),
|
||||
'map': (3, 1, True),
|
||||
'map_rotate': (3, 1, True),
|
||||
}
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.data.get(
|
||||
key, (self.DEFAULT_TIMEOUT, self.DEFAULT_FRAGMENT_READ_TIMEOUT, False)
|
||||
)
|
||||
|
||||
|
||||
_config = Config()
|
||||
|
||||
|
||||
def get(key: str):
|
||||
match key:
|
||||
case 'fast_restart' | 'fastrestart':
|
||||
return _config['fast_restart']
|
||||
case 'map_restart' | 'maprestart':
|
||||
return _config['map_restart']
|
||||
case 'map_rotate' | 'maprotate':
|
||||
return _config['map_rotate']
|
||||
case _:
|
||||
return _config[key]
|
||||
Reference in New Issue
Block a user