Canonical template for sgnd-console modules
Source: target-root/usr/local/lib/solidgroundux/templates/mod-template.sh
Canonical template for sgnd-console modules
Public functions
Internal functions
| Function | Purpose | Arguments | Output |
|---|---|---|---|
_sgnd_lib_guard | Ensure the file is sourced as a library and initialized only once. | — | — |
_sample_format_status | Format a status value for display by a public module action. | - $1: Optional: validation status. | (stdout): |
Description
Provides the standard structure for modules that extend sgnd-console with:
- one or more menu groups
- one or more registered menu actions
- optional internal helper functions
Console modules are source-only plugin libraries. Their only intended load-time side effect is self-registration with sgnd-console.
Design principles
- Modules define functions first, then register themselves explicitly
- Registration is data-driven through the public sgnd_menu_register_group/item API
- Keep module logic local and menu-facing
- Avoid framework-wide policy decisions inside modules
Role in framework
- Extends sgnd-console with domain-specific actions and menu entries
- Acts as a lazy-loaded page/plugin layer on top of the console host
- May depend on framework and console common libraries declared by the host, but not on another page module having been opened
Assumptions:
- Lazy-loaded by sgnd-console when the module page is first opened
- sgnd_menu_register_group and sgnd_menu_register_item are available
- Framework helpers such as say and sgnd_print_ may be used
Non-goals
- Standalone execution
- Bootstrap, path resolution, or framework initialization
- Full-screen UI behavior outside the sgnd-console host
Module metadata
Replace SAMPLE_MODULE in all variable names and values below. MODULE_NAME remains a literal quoted assignment for lightweight page discovery. Version and description are read from the canonical comment header.
