mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-18 15:46:46 -08:00
feat: pass fzf opts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -15,11 +16,8 @@ class FzfSelector(BaseSelector):
|
|||||||
if not self.executable:
|
if not self.executable:
|
||||||
raise FileNotFoundError("fzf executable not found in PATH.")
|
raise FileNotFoundError("fzf executable not found in PATH.")
|
||||||
|
|
||||||
|
os.environ["FZF_DEFAULT_OPTS"] = self.config.opts
|
||||||
# You can prepare default opts here from the config
|
# You can prepare default opts here from the config
|
||||||
if config.opts:
|
|
||||||
self.default_opts = self.config.opts.splitlines()
|
|
||||||
else:
|
|
||||||
self.default_opts = []
|
|
||||||
|
|
||||||
def choose(self, prompt, choices, *, preview=None, header=None):
|
def choose(self, prompt, choices, *, preview=None, header=None):
|
||||||
fzf_input = "\n".join(choices)
|
fzf_input = "\n".join(choices)
|
||||||
@@ -43,11 +41,9 @@ class FzfSelector(BaseSelector):
|
|||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
|
|
||||||
def confirm(self, prompt, *, default=False):
|
def confirm(self, prompt, *, default=False):
|
||||||
# FZF is not great for confirmation, but we can make it work
|
|
||||||
choices = ["Yes", "No"]
|
choices = ["Yes", "No"]
|
||||||
default_choice = "Yes" if default else "No"
|
default_choice = "Yes" if default else "No"
|
||||||
# A simple fzf call can simulate this
|
result = self.choose(prompt, choices, header=f"Default: {default_choice}")
|
||||||
result = self.choose(choices, prompt, header=f"Default: {default_choice}")
|
|
||||||
return result == "Yes"
|
return result == "Yes"
|
||||||
|
|
||||||
def ask(self, prompt, *, default=None):
|
def ask(self, prompt, *, default=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user