Library Template

SolidGroundUX DocumentationSolidGroundUX
NL

Canonical template for source-only framework libraries

Source: target-root/usr/local/lib/solidgroundux/templates/lib-template.sh

Canonical template for source-only framework libraries

Internal functions
FunctionPurposeArgumentsOutput
_sgnd_lib_guardEnsure the file is sourced as a library and initialized only once.——

Description

Provides the standard structure for framework libraries, including:

  • canonical script header sections
  • library-only execution guard (must be sourced, never executed)
  • guard variable for detecting prior sourcing
  • naming conventions for internal and public functions
  • reference function header layout

Design principles

  • Libraries define functions and constants only
  • No auto-execution (must always be sourced)
  • Keep behavior deterministic and side-effect aware
  • Separate mechanism (library) from policy (caller)

Role in framework

  • Base template for all SolidGroundUX library modules
  • Defines structure, conventions, and documentation standards

Non-goals

  • Executable scripts (use exe-template.sh)
  • Application logic
  • Framework bootstrap or path resolution

Internal helpers

doc$ Internal helper naming Prefix internal-only helpers with "_" (never "sgnd_"). Example: _<libname>_helper() { :; }

Public API

doc$ Public API naming Prefix public framework functions with "sgnd_" (never "_"). Example: sgnd_<libname>_do_something() { :; } doc$ Default function header <function_name>

Purpose

<one-line description>

Behavior

<optional: key behavior summary when non-trivial>

Arguments

$1 ... $2 ...

Inputs (globals): FOO, BAR (only if used)

Outputs (globals): BAZ (only if set)

Output

Writes ... to stdout/stderr (only if applicable)

Side effects

Creates/updates/deletes files, sets permissions, etc.

Returns

0 on success, non-zero on failure

Usage

<function_name> arg1 arg2

Examples: <function_name> "value"

Notes:

  • Edge cases / gotchas