From: Matthias Kruk Date: Thu, 22 Dec 2022 06:57:48 +0000 (+0900) Subject: toolbox.sh: Don't require interfaces to be included manually X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=50c1e5af53a2ade8692bcfd1a62f6db0ae3ca09d;p=toolbox toolbox.sh: Don't require interfaces to be included manually When a module implements an interface, it has to include the module that defines the interface before calling `implements()'. However, since the name of an interface and the module that defines it are necessarily identical, there is no ambiguity and the module should be included automatically. This commit modifies the function `implements()' so that it includes the interface's module before registering the implementation. --- diff --git a/toolbox.sh b/toolbox.sh index 802c5cc..71e5725 100644 --- a/toolbox.sh +++ b/toolbox.sh @@ -234,6 +234,10 @@ implements() { local method declare -n interface + if ! include "$iface"; then + return 1 + fi + if [[ -z "${__TOOLBOX_INTERFACES[$iface]}" ]]; then echo "ERROR: Unknown interface: \"$iface\"" 1>&2 return 1