MCPcopy
hub / github.com/larksuite/cli / ParseLangFlag

Function ParseLangFlag

internal/cmdutil/lang.go:16–28  ·  view source on GitHub ↗

ParseLangFlag validates and canonicalizes a --lang value, shared by config and profile so every entry point honors one contract. Empty is unset (no-op); a non-empty value must resolve via i18n.Parse or it errors.

(raw string)

Source from the content-addressed store, hash-verified

14// and profile so every entry point honors one contract. Empty is unset (no-op);
15// a non-empty value must resolve via i18n.Parse or it errors.
16func ParseLangFlag(raw string) (i18n.Lang, error) {
17 if raw == "" {
18 return "", nil
19 }
20 lang, ok := i18n.Parse(raw)
21 if !ok {
22 return "", errs.NewValidationError(errs.SubtypeInvalidArgument,
23 "invalid --lang %q; valid values: %s",
24 raw, strings.Join(i18n.Codes(), ", ")).
25 WithParam("--lang")
26 }
27 return lang, nil
28}

Callers 3

profileAddRunFunction · 0.92
validateInitLangFunction · 0.92
validateBindFlagsFunction · 0.92

Calls 4

ParseFunction · 0.92
NewValidationErrorFunction · 0.92
CodesFunction · 0.92
WithParamMethod · 0.80

Tested by

no test coverage detected