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

Function validateEnumFlags

shortcuts/common/runner.go:1118–1140  ·  view source on GitHub ↗
(rctx *RuntimeContext, flags []Flag)

Source from the content-addressed store, hash-verified

1116}
1117
1118func validateEnumFlags(rctx *RuntimeContext, flags []Flag) error {
1119 for _, fl := range flags {
1120 if len(fl.Enum) == 0 {
1121 continue
1122 }
1123 val := rctx.Str(fl.Name)
1124 if val == "" {
1125 continue
1126 }
1127 valid := false
1128 for _, allowed := range fl.Enum {
1129 if val == allowed {
1130 valid = true
1131 break
1132 }
1133 }
1134 if !valid {
1135 return ValidationErrorf("invalid value %q for --%s, allowed: %s", val, fl.Name, strings.Join(fl.Enum, ", ")).
1136 WithParam("--" + fl.Name)
1137 }
1138 }
1139 return nil
1140}
1141
1142func handleShortcutDryRun(f *cmdutil.Factory, rctx *RuntimeContext, s *Shortcut) error {
1143 if s.DryRun == nil {

Callers 2

runShortcutFunction · 0.85

Calls 3

ValidationErrorfFunction · 0.85
WithParamMethod · 0.80
StrMethod · 0.65