๐งฉ Modules
DI supports custom modules designed to extend the environment with new functions, variables, or file operations.
What Are DI Modules?โ
A DI module is a ZIP file containing a module.sh
script at its root. When imported, this script is sourced into the DI environment, allowing it to:
- Define new functions or variables.
- Use all existing DI functions continuously.
- Extract files from itself for additional functionality.
Module Structureโ
my_module.zip
โโโ module.sh # Main script, sourced into DI
โโโ example/extras.txt # Optional files for extraction
import_module
โ
Imports a module ZIP into the DI environment.
import_module <zip_file> [ARGs]
Example:
import_module "/sdcard/my_module.zip" "arg1" "arg2"
- The variable
$1
inmodule.sh
will be/sdcard/my_module.zip
. The variables $2
and$3
will be"arg1"
and"arg2"
.
module.sh:
# Inside my_module.zip/module.sh
module_path="$1"
first_arg="$2"
second_arg="$3"
ui_print "Hello, I'm a module"
ui_print "And I am located in: $module_path"
ui_print "I can extract content from the Main ZIP that called me!"
package_extract_dir "from_main_zip" "/sdcard/output1"
ui_print "I can also extract content from myself!"
package_extract_dir "example" "/sdcard/output1" "$module_path"
ui_print "I leave additional information even after my execution ends:"
EXTRA_VAR="Bye!" # The main script can access this variable
tip
Modules can extract their own files using the variable $1
as the ZIP path, making them self-contained plugins.