import "github.com/yuta-yoshinaga/go_trumpcards/internal/adapter/controller/cuiutil"NoMax is a sentinel value meaning “no upper bound” for ParseIntArg.
const NoMax = math.MaxIntNoMin is a sentinel value meaning “no lower bound” for ParseIntArg.
const NoMin = math.MinIntPromptPrefix is the sentinel prefix indicating a prompt request. When a controller returns a string starting with this prefix, the game loop should prompt the user for the missing argument and re-dispatch the command with the user’s input.
const PromptPrefix = "PROMPT:"func FillTemplate(template, value string) stringFillTemplate replaces the {0} placeholder in template with value.
func FormatSkippedWarning(skipped []string) stringFormatSkippedWarning returns a warning string for skipped values. Returns an empty string if skipped is empty.
func IsPromptRequest(s string) boolIsPromptRequest checks if s starts with PromptPrefix.
func LevenshteinDistance(a, b string) intLevenshteinDistance returns the Levenshtein edit distance between two strings.
func ParseBoundedIntSlice(args []string, min, max int) ([]int, []string)ParseBoundedIntSlice parses all elements of args as integers within [min, max], returning skipped or out-of-range values.
func ParseIntArg(args []string, missingMsg, invalidMsg string, min, max int) (int, string, bool)ParseIntArg parses args[0] as an integer within [min, max]. Returns (value, errMsg, ok). If ok is false, errMsg should be returned to the user. missingMsg is returned when args is empty. invalidMsg is returned when the value is non-numeric or out of range. If invalidMsg contains “%s”, it is formatted with args[0] via fmt.Sprintf. Only a single %s verb is supported; %%s and multiple verbs are not handled.
func ParseIntSlice(args []string) ([]int, []string)ParseIntSlice parses all elements of args as integers, returning skipped values.
func ParseOptionalInt(args []string, idx, defaultVal int) intParseOptionalInt parses args[idx] as an integer, returning defaultVal if absent or invalid.
func ParsePromptRequest(s string) (prompt, template string)ParsePromptRequest extracts the prompt message and command template from a prompt request string. Returns empty strings if malformed.
func PrependSkippedWarning(result string, skipped []string) stringPrependSkippedWarning prepends a warning to result if skipped is non-empty.
func PromptRequest(promptMsg, commandTemplate string) stringPromptRequest builds a prompt return string. promptMsg is displayed to the user (e.g., “Enter bet amount:”). commandTemplate is the command to re-dispatch, with {0} as a placeholder for the user’s input (e.g., “b {0}”).
func SuggestCommand(input string, validCommands []string, maxDistance int) stringSuggestCommand returns the closest matching command from validCommands whose edit distance is at most maxDistance. Returns “” if no match is found.
func WithParsedInt(args []string, missingMsg, invalidMsg string, min, max int, fn func(int) string) (string, bool)WithParsedInt はParseIntArgの結果を処理するヘルパー。 パース失敗時は (errMsg, true) を返し、成功時は fn(value) の結果を (result, true) で返す。 戻り値の bool は常に true(コマンドが処理済みであることを示す)。
Generated by gomarkdoc