]> git.corax.cc Git - toolbox/commitdiff
toolbox.sh: Don't require interfaces to be included manually
authorMatthias Kruk <m@m10k.eu>
Thu, 22 Dec 2022 06:57:48 +0000 (15:57 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 9 Jan 2023 04:20:17 +0000 (13:20 +0900)
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.

toolbox.sh

index 802c5cc823f25c7ebe5e8a2934d0d737a2b82aeb..71e5725fa6c9f27824b94fba6209fa3a56786e22 100644 (file)
@@ -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