Documentation
¶
Overview ¶
Package shared provides common helper functions used across commands, mcpserver, and tui packages.
Index ¶
- func ExtractNutritionBlock(payload any) any
- func FormatMoneyValue(v any) string
- func LocalizedString(v any) string
- func MoneyString(v any) string
- func ProductNameFromMap(m map[string]any) string
- func StringFieldFromMap(m map[string]any, keys ...string) string
- func TruncateText(s string, maxLen int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractNutritionBlock ¶
ExtractNutritionBlock walks a JSON payload recursively and returns the first value whose key contains "nutrition", "nutri", or "odzyw" (case-insensitive).
func FormatMoneyValue ¶
FormatMoneyValue formats a single numeric or string value as a money string. Unlike MoneyString, this does not recurse into maps with domain-specific keys like "_total" or "FRS"; it only handles the leaf value types and a generic map with "price"/"gross"/"amount"/"value" keys.
func LocalizedString ¶
LocalizedString extracts a string from a value that may be a plain string, a locale map (e.g. {"pl": "...", "en": "..."}), or another nested structure. It prefers "pl", then "en".
func MoneyString ¶
MoneyString converts a value (number, string, or nested price map) to a formatted money string like "12.34". Returns "" when no value can be extracted.
func ProductNameFromMap ¶
ProductNameFromMap extracts a human-readable product name from a map, trying common Frisco API key names in priority order.
func StringFieldFromMap ¶
StringFieldFromMap looks up the first non-empty string value from a map trying each key in order.
func TruncateText ¶
TruncateText truncates a string to max runes, appending "..." if shortened.
Types ¶
This section is empty.