Entering ? on the post link screen now displays category details
This commit is contained in:
parent
e2a78fd68f
commit
02092ba048
27
linkulator
27
linkulator
|
@ -194,6 +194,17 @@ def get_input(item: str) -> str:
|
|||
i: str = input("{}: ".format(style_text(item, "underline")))
|
||||
if i == "":
|
||||
raise ValueError("Empty field")
|
||||
if i == "?":
|
||||
category_text = (
|
||||
"No categories yet, feel free to make a new one!"
|
||||
if not categories
|
||||
else ", ".join(sorted(record["name"] for record in categories))
|
||||
)
|
||||
print(
|
||||
"Available categories: {}\n"
|
||||
"♻️ Please help keep Linkulator tidy".format(category_text)
|
||||
)
|
||||
continue
|
||||
if is_valid_input(i):
|
||||
return i
|
||||
print(
|
||||
|
@ -204,21 +215,15 @@ def get_input(item: str) -> str:
|
|||
|
||||
def post_link() -> int:
|
||||
"""Handles the link posting process"""
|
||||
|
||||
category_text = (
|
||||
"None"
|
||||
if not categories
|
||||
else ", ".join(sorted(record["name"] for record in categories))
|
||||
print("\nPost a link by entering the details below.")
|
||||
print(
|
||||
"Enter {} for a list of categories. Enter an empty field to cancel.\n".format(
|
||||
style_text("?", "underline")
|
||||
)
|
||||
)
|
||||
|
||||
print("\nEnter link information here. Leaving any field blank aborts " "post.\n")
|
||||
|
||||
try:
|
||||
url = get_input("URL")
|
||||
print(
|
||||
"Available categories: {}\n"
|
||||
"♻️ Please help keep Linkulator tidy".format(category_text)
|
||||
)
|
||||
category = get_input("Category")
|
||||
title = get_input("Title")
|
||||
except ValueError:
|
||||
|
|
Loading…
Reference in New Issue