Commit c295b620 authored by David Huss's avatar David Huss 💬
Browse files

Increase -e comfort, add more documentation

If the user provides a wrong parameter with --endpoint/-e
Instead of simply telling them they are wrong, list the available
endpoints instead.

Additionally display a warning if users are on server, so they know
their local config is ignored
parent e6294777
......@@ -77,6 +77,10 @@ class Config():
return self
def filter_endpoints(self, endpoint_options: List[str]) -> 'Config':
"""
Return a Config that only contains the matching endpoints. If the endpoint
isn't found, return a Error message.
"""
if len(endpoint_options) == 0:
return self
else:
......@@ -85,6 +89,13 @@ class Config():
for endpoint_option in endpoint_options:
if not endpoint_option in existing_names:
click.echo("{} there is no endpoint called \"{}\" in the configuration. It will be ignored.\n".format(click.style('Error:', fg='red', bold=True), click.style(endpoint_option, fg='red', bold=True)))
if self.on_server:
click.echo("{} bbbmon is using the server config. You can use a user config using the {} flag.\n".format(click.style('Hint:', fg='yellow', bold=True), click.style("--userconfig", fg='bright_black', bold=True)))
if len(self.endpoints) > 0:
click.echo("{}".format(click.style('Available Endpoints:', fg='green', bold=True)))
for endpoint in self.endpoints:
click.echo(" → {}".format(click.style(endpoint.name, fg='green', bold=True)))
else:
filtered_endpoints.append([e for e in self.endpoints if e.name == endpoint_option][0])
......
......@@ -186,7 +186,8 @@ def list_meetings(config: Config, leaderboards: bool, n: int, participants: bool
def meetings_twolines(config: Config, watch: int, fancy: bool):
"""
For each endpoint in the configuration get the active meetings and print
out an overview of the current bbb-usage
out an overview of the current bbb-usage. This is guaranteed to fit within
60 characters and two lines
"""
# Request Meetings from API
......
......@@ -10,7 +10,7 @@ import bbbmon.meetings
# This is used as Leaderboard names
FRIENDLY_KEYNAMES = {
"participantCount" : "Participants",
"listenerCount" : "only listening",
......@@ -134,10 +134,16 @@ def print_duration_leaderboard(meetings: Iterable[XmlDictConfig], n: int, endpoi
def print_header(endpoint_name: str, text: str, fancy=True, newline=True):
"""
Print a section header
"""
click.echo(format_header(endpoint_name, text, fancy), nl=newline)
def format_header(endpoint_name: str, text: str, fancy=True) -> str:
"""
Format a header and return a string
"""
if fancy:
if len(endpoint_name) > 0:
block = click.style(" [{}] {} ".format(endpoint_name, text), fg='black', bg='white', bold=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment