Skip to content

Commit

Permalink
refactor commands.py into multiple packages and modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen committed Sep 16, 2021
1 parent 6e1c1ea commit afbecbf
Show file tree
Hide file tree
Showing 56 changed files with 1,702 additions and 1,404 deletions.
31 changes: 31 additions & 0 deletions esque/cli/autocomplete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from esque.cli.options import State
from esque.controller.consumergroup_controller import ConsumerGroupController
from esque.resources.broker import Broker


def list_brokers(ctx, args, incomplete):
state = ctx.ensure_object(State)
all_broker_hosts_names = [f"{broker.host}:{broker.port}" for broker in Broker.get_all(state.cluster)]
return [broker for broker in all_broker_hosts_names if broker.startswith(incomplete)]


def list_consumergroups(ctx, args, incomplete):
state = ctx.ensure_object(State)
return [
group
for group in ConsumerGroupController(state.cluster).list_consumer_groups()
if group.startswith(incomplete)
]


def list_contexts(ctx, args, incomplete):
state = ctx.ensure_object(State)
return [context for context in state.config.available_contexts if context.startswith(incomplete)]


def list_topics(ctx, args, incomplete):
state = ctx.ensure_object(State)
cluster = state.cluster
return [
topic.name for topic in cluster.topic_controller.list_topics(search_string=incomplete, get_topic_objects=False)
]
Loading

0 comments on commit afbecbf

Please sign in to comment.