Ignore non .ini files, exit on no selection

This commit is contained in:
Loïc Gremaud 2024-05-28 01:09:36 +02:00
parent 2a4ba5ed92
commit 5c5d2c4927
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D

View File

@ -14,6 +14,8 @@ BASE_PATH = Path("~/.ssh-tmux/").expanduser()
configs = {} configs = {}
sections = {} sections = {}
for subconffile in os.listdir(BASE_PATH): for subconffile in os.listdir(BASE_PATH):
if not subconffile.endswith(".ini"):
continue
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(BASE_PATH / subconffile) config.read(BASE_PATH / subconffile)
@ -24,7 +26,11 @@ for subconffile in os.listdir(BASE_PATH):
fzf = FzfPrompt() fzf = FzfPrompt()
selected_group = fzf.prompt(sections.keys(), "--cycle")[0] selections = fzf.prompt(sections.keys(), "--cycle")
if not selections:
sys.exit(0)
selected_group = selections[0]
config = configs[sections[selected_group]] config = configs[sections[selected_group]]