From 3009d3831e826d29226545b9c0263c363f60c05d Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 30 Aug 2025 20:36:36 -0700 Subject: [PATCH] Elborated rename function to recommend --- ucsinfer/__main__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ucsinfer/__main__.py b/ucsinfer/__main__.py index c22fcc7..1d62d46 100644 --- a/ucsinfer/__main__.py +++ b/ucsinfer/__main__.py @@ -28,13 +28,19 @@ def print_recommendation(path: str | None, text: str, ctx: InferenceContext, print(f"- {i}: {r} ({cat}-{subcat})") if interactive_rename and path is not None: - response = input("Enter number, or any key to skip: ") - if match(r'^[0-9]+\n', response): - selection = int(response) + response = input("Enter number, t for alternate text, or " + "return to skip: ") + + if m := match(r'^([0-9]+)', response): + selection = int(m.group(1)) if 0 <= selection < len(recs): new_name = recs[selection] + '_' + os.path.basename(path) new_path = os.path.join(os.path.dirname(path), new_name) os.rename(path, new_path) + elif m := match(r'^t (.*)', response): + print("searching for new matches") + text = m.group(1) + print_recommendation(path, text, ctx, True) @click.group(epilog="For more information see "