From c2510da0ca940a8c9493b6e67f8a10db08baaac1 Mon Sep 17 00:00:00 2001 From: keyboard-slayer Date: Mon, 13 Nov 2023 20:37:41 +0100 Subject: [PATCH] fix: check plugin if script is in same directory as __init__.py --- cutekit/cli.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cutekit/cli.py b/cutekit/cli.py index 74fed4f..188b2af 100644 --- a/cutekit/cli.py +++ b/cutekit/cli.py @@ -1,6 +1,7 @@ import inspect import sys +from pathlib import Path from typing import Optional, Union, Callable from dataclasses import dataclass @@ -80,19 +81,19 @@ class Command: commands: list[Command] = [] -def append(command: Command): - command.isPlugin = True - commands.append(command) - commands.sort(key=lambda c: c.shortName or c.longName) - - def command(shortName: Optional[str], longName: str, helpText: str): curframe = inspect.currentframe() calframe = inspect.getouterframes(curframe, 2) def wrap(fn: Callable[[Args], None]): commands.append( - Command(shortName, longName, helpText, calframe[1].filename != __file__, fn) + Command( + shortName, + longName, + helpText, + Path(calframe[1].filename).parent != Path(__file__).parent, + fn, + ) ) return fn