diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-16 22:21:36 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-16 22:21:36 +0300 |
| commit | 14d041e890765afbab396a29871d6bf6e8097fff (patch) | |
| tree | e3fcdc084b75bbd7ec294489a72966e03d7f6ed1 /src/lib/logging.source.sh | |
| parent | aca23d3a094cb1bf86db40e42f184fbf88371d42 (diff) | |
jn0 split bootstrap.source.sh into logging/paths/startup modules
Separate the mixed concerns in bootstrap.source.sh per [SRP]:
- logging.source.sh: output_is_quiet, output_is_verbose, log_info,
log_verbose, log_warning (the output/logging concern).
- paths.source.sh: resolve_default_rc_file, resolve_source_root,
resolve_default_template_dir, resolve_default_asset_dir,
template_dir_uses_default, apply_template_dir_default, init_config
(install/source-root/default-dir + rc-file/template-dir resolution).
- bootstrap.source.sh keeps the CLI usage text and the shared
resolve_config_array parser used by the config modules.
Pure code move, verified byte-identical function bodies. LIB_SOURCES now
lists logging.source.sh first, then bootstrap, then paths; matching
source directives added to src/shuriken.sh so --check-sourced sees the
new modules. just test/shellcheck/check-generated and git diff --check
all pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/logging.source.sh')
| -rw-r--r-- | src/lib/logging.source.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/logging.source.sh b/src/lib/logging.source.sh new file mode 100644 index 0000000..b627b04 --- /dev/null +++ b/src/lib/logging.source.sh @@ -0,0 +1,30 @@ +# Output/logging utilities. Split out of bootstrap.source.sh (task jn0) so the +# "how do we print to the user" concern lives apart from startup wiring and path +# resolution. These helpers read the SHURIKEN_OUTPUT_MODE global and are called +# from nearly every other module, so this file is kept early in LIB_SOURCES. +# All library modules are sourced before any code runs, so definition order does +# not affect availability. + +output_is_quiet() { + [ "$SHURIKEN_OUTPUT_MODE" = quiet ] +} + +output_is_verbose() { + [ "$SHURIKEN_OUTPUT_MODE" = verbose ] +} + +log_info() { + if ! output_is_quiet; then + printf '%s\n' "$*" + fi +} + +log_verbose() { + if output_is_verbose; then + printf 'Verbose: %s\n' "$*" + fi +} + +log_warning() { + printf 'WARNING: %s\n' "$*" >&2 +} |
