MCPcopy Create free account
hub / github.com/compozy/agh / parseAutomationFilterFlags

Function parseAutomationFilterFlags

internal/cli/automation.go:1121–1155  ·  view source on GitHub ↗
(flags []string)

Source from the content-addressed store, hash-verified

1119}
1120
1121func parseAutomationFilterFlags(flags []string) (map[string]string, error) {
1122 if len(flags) == 0 {
1123 return nil, nil
1124 }
1125
1126 filter := make(map[string]string)
1127 for _, rawFlag := range flags {
1128 for entry := range strings.SplitSeq(rawFlag, ",") {
1129 trimmedEntry := strings.TrimSpace(entry)
1130 if trimmedEntry == "" {
1131 continue
1132 }
1133 key, value, ok := strings.Cut(trimmedEntry, "=")
1134 if !ok {
1135 return nil, fmt.Errorf("cli: invalid filter %q: use key=value", trimmedEntry)
1136 }
1137 key = strings.TrimSpace(key)
1138 value = strings.TrimSpace(value)
1139 if key == "" {
1140 return nil, fmt.Errorf("cli: invalid filter %q: key is required", trimmedEntry)
1141 }
1142 if value == "" {
1143 return nil, fmt.Errorf("cli: invalid filter %q: value is required", trimmedEntry)
1144 }
1145 filter[key] = value
1146 }
1147 }
1148 if len(filter) == 0 {
1149 return nil, nil
1150 }
1151 if err := automationpkg.ValidateTriggerFilter(filter, "filter"); err != nil {
1152 return nil, fmt.Errorf("cli: %w", err)
1153 }
1154 return filter, nil
1155}
1156
1157func parseAutomationOptionalTimeFlag(
1158 raw string,

Calls

no outgoing calls

Tested by

no test coverage detected