wip: Refactor get_input to handle single file input.

This commit is contained in:
Paul Gauthier 2023-05-10 10:07:08 -07:00
parent 24b40f6982
commit 000c917302

View file

@ -1,4 +1,7 @@
import os
import re
from pathlib import Path
from prompt_toolkit.styles import Style
from prompt_toolkit import prompt
@ -45,11 +48,15 @@ def canned_input(show_prompt):
return input_line
import os
def get_input(history_file, fnames):
common_prefix = os.path.commonprefix(fnames)
short_fnames = [fname.replace(common_prefix, '', 1) for fname in fnames]
fnames = list(fnames)
if len(fnames) > 1:
common_prefix = os.path.commonprefix(fnames)
short_fnames = [fname.replace(common_prefix, '', 1) for fname in fnames]
else:
short_fnames = [Path(fnames[0]).name]
show = ' '.join(short_fnames)
show += "\n> "