mirror of
https://github.com/onyx-and-iris/q3rcon-cli.git
synced 2026-03-24 02:39:18 +00:00
add --version flag
This commit is contained in:
parent
60afda97dc
commit
26a00bff42
@ -73,6 +73,7 @@ Usage: q3rcon-cli [OPTIONS] COMMAND
|
||||
|
||||
┏━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ -i, --interactive Whether to start in interactive mode (defaults to false) ┃
|
||||
┃ -v, --version Show the version and exit ┃
|
||||
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
|
||||
┏━ Connection options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
|
||||
@ -4,6 +4,7 @@ from clypi import Command, Spinner, arg
|
||||
from typing_extensions import override
|
||||
|
||||
from . import console
|
||||
from .__about__ import __version__
|
||||
from .commands import (
|
||||
Fastrestart,
|
||||
Gametype,
|
||||
@ -57,9 +58,18 @@ class Q3rconCli(Command):
|
||||
short='i',
|
||||
help='Whether to start in interactive mode (defaults to false)',
|
||||
)
|
||||
version: bool = arg(
|
||||
False,
|
||||
short='v',
|
||||
help='Show the version and exit',
|
||||
)
|
||||
|
||||
@override
|
||||
async def run(self):
|
||||
if self.version:
|
||||
print(f'q3rcon-cli version: {clypi.style(__version__, fg="green")}')
|
||||
return
|
||||
|
||||
if self.interactive:
|
||||
await self.run_interactive()
|
||||
else:
|
||||
@ -68,7 +78,7 @@ class Q3rconCli(Command):
|
||||
async def run_interactive(self):
|
||||
print(
|
||||
clypi.style('Entering interactive mode. Type', fg='blue'),
|
||||
clypi.style("'Q'", fg='red'),
|
||||
clypi.style("'Q'", fg='yellow'),
|
||||
clypi.style('to quit.', fg='blue'),
|
||||
)
|
||||
|
||||
@ -99,14 +109,14 @@ class Q3rconCli(Command):
|
||||
fragment_read_timeout=fragment_read_timeout,
|
||||
) as client:
|
||||
try:
|
||||
if response := await client.send_command(
|
||||
response = await client.send_command(
|
||||
command, interpret=interpret
|
||||
):
|
||||
console.out.print_response(response)
|
||||
)
|
||||
except TimeoutError:
|
||||
console.err.print(
|
||||
f"Timeout waiting for response for command: '{command}'"
|
||||
)
|
||||
console.out.print_response(response)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@ -52,7 +52,7 @@ class OutConsole(Console):
|
||||
def print_response(self, response: str):
|
||||
response = self._remove_colour_codes(response).removeprefix('print\n')
|
||||
|
||||
cprint(f'\n{response}\n', fg=self.style)
|
||||
cprint(response, fg=self.style)
|
||||
|
||||
def print_status(self, response: str):
|
||||
_slots = []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user