diff --git a/.github/workflows/Publish Release.yml b/.github/workflows/Publish Release.yml index 8b4c6a4..d759c7a 100644 --- a/.github/workflows/Publish Release.yml +++ b/.github/workflows/Publish Release.yml @@ -33,7 +33,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r ./requirements.txt -t ./lib - zip -r Flow.Launcher.Plugin.ZoxidePy.zip . -x '*.git*' + zip -r Flow.Launcher.Plugin.ZoxidePy.zip . -x '*.git*' '*.venv*' - name: Publish if: success() uses: softprops/action-gh-release@v1 diff --git a/src/zoxide.py b/src/zoxide.py index 11cfa7c..f423cf2 100644 --- a/src/zoxide.py +++ b/src/zoxide.py @@ -5,11 +5,10 @@ from typing import List from pyflowlauncher import Result, ResultResponse, send_results -from pyflowlauncher.api import copy_to_clipboard -from pyflowlauncher.icons import COPY, FOLDER, RECYCLEBIN +from pyflowlauncher.api import copy_to_clipboard, open_url +from pyflowlauncher.icons import COPY, FOLDER, RECYCLEBIN, WEB_SEARCH from src.error import ( ZoxideAddError, - ZoxideNotFound, ZoxideQueryError, ZoxideRemoveError, ZoxideResultParseError, @@ -32,7 +31,15 @@ def _get_zoxide_path(self, plugin) -> str: if os.path.exists(zoxide_path) or shutil.which(zoxide_path) is not None: return zoxide_path else: - raise ZoxideNotFound(zoxide_path) + return "" + + def _get_zoxide_not_found_result(self) -> Result: + return Result( + Title="Zoxide not found", + SubTitle="Download and install zoxide", + IcoPath=WEB_SEARCH, + JsonRPCAction=open_url("https://github.com/ajeetdsouza/zoxide"), + ) def zoxide_add(self, path: str) -> bool: cmd = [self.zoxide_path, "add", path.strip()] @@ -116,6 +123,8 @@ def generate_context_menu(self, path: str) -> List[Result]: return results def cd(self, query: str) -> ResultResponse: + if not self.zoxide_path: + return send_results([self._get_zoxide_not_found_result()]) if not query.strip(): return send_results([]) @@ -145,6 +154,8 @@ def cd(self, query: str) -> ResultResponse: ) def open(self, query: str) -> ResultResponse: + if not self.zoxide_path: + return send_results([self._get_zoxide_not_found_result()]) if not query.strip(): return send_results([])