upd: essential/file updated
helper status updated
This commit is contained in:
parent
ab6b3267ef
commit
483370b4c0
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user