From 483370b4c05d036ee44b2a44a4986e13cf3e49a2 Mon Sep 17 00:00:00 2001 From: Rajon Ahmed Date: Fri, 28 Aug 2026 12:59:02 +0800 Subject: [PATCH] upd: essential/file updated helper status updated --- .../visible/service/helper/status/status.go | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/essential/visible/service/helper/status/status.go b/essential/visible/service/helper/status/status.go index e69de29..ebaea2f 100644 --- a/essential/visible/service/helper/status/status.go +++ b/essential/visible/service/helper/status/status.go @@ -0,0 +1,114 @@ +/* +|-------------------------------------------------------------------------- +| Description +|-------------------------------------------------------------------------- +| +| Name: +| - Status +| +| Purpose: +| - Provide a framework-level CLI status utility that standardizes +| terminal message presentation using semantic labels and visual +| indicators to ensure consistent output across all softwares. +| +|-------------------------------------------------------------------------- +*/ + +/* +|-------------------------------------------------------------------------- +| Instruction +|-------------------------------------------------------------------------- +| +| Guideline: +| - Accept a semantic status category and human-readable message. +| - Use INFO, WARNING, SUCCESS, and ERROR as supported status labels. +| - Treat unsupported, empty, or invalid labels as INFO. +| - Emit exactly one standardized terminal message per invocation. +| +| Example: +| - ObrimStatus( +| "INFO", +| "Application started successfully.", +| ) +| +| - ObrimStatus( +| "WARNING", +| "Configuration file not found.", +| ) +| +| - ObrimStatus( +| "SUCCESS", +| "Installation completed.", +| ) +| +| - ObrimStatus( +| "ERROR", +| "Unable to connect to the server.", +| ) +| +|-------------------------------------------------------------------------- +*/ + +/* +|-------------------------------------------------------------------------- +| Credit +|-------------------------------------------------------------------------- +| +| Contributor: +| - Rajon Ahmed +| - Blockonite +| +|-------------------------------------------------------------------------- +*/ + +package status + +import ( + "fmt" + "strings" +) + +// ObrimStatus emits a standardized terminal message. +func ObrimStatus(label, message string) { + normalizedLabel, normalizedMessage := obrimStatusValidateInput(label, message) + output := obrimStatusBuildOutput(obrimStatusFormatMessage(normalizedLabel, normalizedMessage)) + + fmt.Print(output) +} + +// obrimStatusValidateInput normalizes and validates the status label and message. +func obrimStatusValidateInput(label, message string) (string, string) { + normalizedLabel := strings.ToUpper(strings.TrimSpace(label)) + normalizedMessage := strings.TrimSpace(message) + + switch normalizedLabel { + case "INFO", "WARNING", "SUCCESS", "ERROR": + default: + normalizedLabel = "INFO" + } + + return normalizedLabel, normalizedMessage +} + +// obrimStatusFormatMessage formats the status label and message with its visual indicator. +func obrimStatusFormatMessage(label, message string) string { + var indicator string + + switch label { + case "WARNING": + indicator = "!" + case "SUCCESS": + indicator = "✓" + case "ERROR": + indicator = "✗" + default: + indicator = "ℹ" + } + + return fmt.Sprintf("[%s %s] %s\n", indicator, label, message) +} + +// obrimStatusBuildOutput builds the final terminal message. +func obrimStatusBuildOutput(message string) string { + return message +} \ No newline at end of file