Merge branch 'post-link-categories' of cmccabe/linkulator2 into master

This commit is contained in:
cmccabe 2019-12-15 22:24:46 -05:00 committed by Gitea
commit 326b889b8e
1 changed files with 16 additions and 11 deletions

View File

@ -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: