Skip to content

Commit

Permalink
improve approval message
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen committed Sep 29, 2021
1 parent 730931f commit d3ba5c8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions esque/cli/commands/create/topic.py
Expand Up @@ -5,6 +5,7 @@
from esque.cli.autocomplete import list_topics
from esque.cli.helpers import ensure_approval, fallback_to_stdin
from esque.cli.options import State, default_options
from esque.cli.output import blue_bold
from esque.resources.topic import Topic


Expand Down Expand Up @@ -40,10 +41,6 @@ def create_topic(
If both <template_topic> and any of the <partitions> or <replication-factor> options are given, then <partitions>
or <replication-factor> takes precedence over corresponding attributes of <template_topic>.
"""
if not ensure_approval("Are you sure?", no_verify=state.no_verify):
click.echo(click.style("Aborted!", bg="red"))
return

topic_controller = state.cluster.topic_controller

if like:
Expand All @@ -60,5 +57,16 @@ def create_topic(

topic = Topic(topic_name, num_partitions=partitions, replication_factor=replication_factor, config=config)

if not ensure_approval(
f"Create topic {blue_bold(topic.name)} "
+ f"with replication factor {blue_bold(str(topic.replication_factor))} "
+ f"and {blue_bold(str(topic.num_partitions))} partition"
+ ("s" if partitions != 1 else "")
+ f" in context {blue_bold(state.config.current_context)}?",
no_verify=state.no_verify,
):
click.echo(click.style("Aborted!", bg="red"))
return

topic_controller.create_topics([topic])
click.echo(click.style(f"Topic with '{topic.name}' successfully created.", fg="green"))

0 comments on commit d3ba5c8

Please sign in to comment.