Provide a modular console interface for SolidGroundUX tooling
Source: target-root/usr/local/libexec/solidgroundux/management-console.sh
Provide a modular console interface for SolidGroundUX tooling
Public functions
- Read persisted status for a menu action
- Persist and display an action result
- Execute one registered action and track its result
- Run the SolidGround management console
Internal functions
| Function | Purpose | Arguments | Output |
|---|---|---|---|
_sgnd_console_state_owner | Keep per-user console state owned by the invoking standard user when the | — | Writes the target user name to stdout. |
_sgnd_console_prepare_state_directory | Create a per-user state directory with restricted permissions and ensure | - $1 DIRECTORY - State directory to prepare. | — |
_sgnd_console_finalize_state_file | Restrict a state file to its owner and restore the invoking user's ownership | - $1 FILE - State file that was just created or replaced. | — |
_sgnd_console_init_paths | Derive console host paths from SGND_FRAMEWORK_ROOT. | — | — |
_sgnd_console_resolve_app_root | Derive the root of the management application tree independently from the | - $1 MODULE_PATH - Selected module file or directory. | Writes the resolved application root to stdout. |
_sgnd_console_set_app_context | Establish the management-application root and executable locations from the | - $1 MODULE_PATH - Selected module source used to resolve application directories. | — |
_sgnd_console_load_config | Resolve the module file or directory used by this console instance. | — | (globals): |
_sgnd_console_execute_menu_item | Execute menu actions through the console tracking layer while leaving | - $1 ITEM_KEY - Registered menu item key. | — |
_sgnd_console_refresh_action_statuses | Populate the current menu items with their previously persisted | — | — |
_sgnd_console_reset_page_results | Reset the persisted last-run status for every non-builtin action belonging | — | — |
_sgnd_console_register_builtin_items | Add the hidden previous/next page controls used by the menu dispatcher. | — | — |
_sgnd_console_register_fallback_group | Register a fallback group for an item that references an unknown group key. | - $1 GROUP_KEY | — |
_sgnd_console_group_exists | Test whether a group key already exists in the console group model. | - $1 GROUP_KEY | — |
_sgnd_console_show_module_metadata | Display lightweight metadata for every console module present in the configured | — | — |
_sgnd_console_module_id_from_filename | Strip the optional two-digit prefix and .sh extension from a module's | - $1 MODULE_FILE - Path or filename of a numbered module. | — |
_sgnd_console_module_state_get | Read the module's persisted enabled/disabled state, defaulting to | - $1 MODULE_ID - Filename-derived module identifier. | — |
_sgnd_console_module_enabled | Return success when a module is enabled (or has no saved state), | - $1 MODULE_ID - Filename-derived module identifier. | — |
_sgnd_console_module_state_set | Save one module's enabled/disabled state without sourcing that module. | - $1 MODULE_ID - Filename-derived console module ID. | — |
_sgnd_console_manage_visibility | Let a root console session enable or disable discovered management pages. | — | — |
_sgnd_console_discover_module_files | List the selected module file or enumerate .sh files in the selected | — | — |
_sgnd_console_module_metadata | Read lightweight page identity plus canonical header version and description. | - $1 MODULE_FILE - Console module file. | — |
_sgnd_console_register_pages | Discover enabled module files and register page metadata without sourcing them. | — | — |
_sgnd_console_open_page | Source a module the first time its index page is selected and activate its menu rows. | - $1 PAGE_INDEX - Zero-based row index in SGND_CONSOLE_PAGE_ROWS. | — |
_sgnd_console_show_index | Show all enabled console pages without loading their implementation modules. | — | — |
_sgnd_console_rollback_module_registration | Restore the console registration model to its pre-load state when a module | - $1 GROUP_COUNT Group-row count before module loading. | — |
_sgnd_console_source_module | Load a selected console module and register its page only after | - $1 MODULE_FILE | (globals): |
_sgnd_build_command_args | Copy caller arguments into a target array and prepend --dryrun when the console | - $1 RESULT_ARRAY - Name of the array receiving arguments. | — |
_sgnd_run_public_command | Resolve a command from the console bin/sbin roots or PATH, propagate console | - $1 COMMAND - Public SolidGroundUX command name. | — |
_sgnd_run_module_script | Locates and executes a console helper script from the canonical | - $1 Script filename. | — |
_sgnd_console_open_shell | Open a new interactive shell and return to the Management Console on exit. | — | — |
_sgnd_console_toggle_access | Replace the current console process with a root or standard-access instance. | — | — |
_sgnd_console_confirm_exit | Require explicit confirmation when Esc is pressed on the top-level console index. | — | — |
_sgnd_console_toggle_dryrun | Switch FLAG_DRYRUN between dry-run and commit mode and redraw immediately. | — | (globals) |
_sgnd_console_cycle_loglevel_value | Resolve and print the adjacent supported framework log level, | - $1 Current log level. | — |
_sgnd_console_persist_framework_value | Save a quick-access setting to SGND_FRAMEWORK_STATEFILE when framework state | - $1 KEY - Framework state variable name. | — |
_sgnd_console_cycle_console_loglevel | Select the adjacent console log level, persist it, and redraw immediately. | - $1 DIRECTION - Optional: 1 forward (default), -1 backward. | — |
_sgnd_console_cycle_file_loglevel | Select the adjacent file log level, persist it, and redraw immediately. | - $1 DIRECTION - Optional: 1 forward (default), -1 backward. | — |
_sgnd_console_cycle_theme | Select the adjacent installed style file, apply it through sgnd_theme, and | - $1 DIRECTION - Optional: 1 forward (default), -1 backward. | — |
_sgnd_console_handle_control | Handle console-wide direct controls before index or module-page dispatch. | - $1 CONTROL - Normalized key returned by sgnd_menu_read_choice. | — |
_sgnd_console_run | Run the interactive console event loop. | — | — |
Description
Provides a generic, modular console host that discovers management pages at startup and lazy-loads each implementation module when its page is first opened.
The script:
- Discovers enabled console modules and reads lightweight page metadata
- Renders a top-level index without sourcing module implementations
- Sources each selected page module once and retains it for the console session
- Allows loaded modules to register menu groups and items dynamically
- Builds and renders interactive menus
- Handles user input, page navigation, paging, and action dispatch
- Persists console layout and framework UI/logging state
Design principles
- Modular architecture with clear separation of host and modules
- Convention-based module registration
- Minimal assumptions about module implementation
- Consistent user interaction patterns across all tools
Role in framework
- Generic console engine for module-defined interactive applications
- Hosts functionality registered by ordered console modules
Non-goals
- Implementing business logic directly in the console host
- Managing module-specific state beyond registration and dispatch
- Providing a widget-based or cursor-addressed full-screen TUI
Usage
Run the executable from its shell command (or installed wrapper):
sgnd-console
sgnd-console --appcfg ./10-sgnd-config.sh
sgnd-console --appcfg ./20-machine-config.sh
Script-specific options:
--appcfg VALUE: Console module file or module directory.--maxrows VALUE: Maximum menu rows per page.--title VALUE: Override console title.
Script metadata (framework integration)
Console module API
Public menu registration functions are defined by sgnd-menu.sh. Modules should use sgnd_menu_register_group/item; the public sgnd_console_register_group/item compatibility API remains available there.
