MCPcopy Create free account
hub / github.com/SaadBelfqih/apple-ads-cli / parseSelectorJSON

Function parseSelectorJSON

cmd/helpers.go:35–58  ·  view source on GitHub ↗

parseSelectorJSON parses JSON from a string or @file.

(input string)

Source from the content-addressed store, hash-verified

33
34// parseSelectorJSON parses JSON from a string or @file.
35func parseSelectorJSON(input string) (*types.Selector, error) {
36 var data []byte
37 var err error
38
39 if strings.HasPrefix(input, "@") {
40 path := input[1:]
41 if path == "-" {
42 data, err = readStdin()
43 } else {
44 data, err = os.ReadFile(path)
45 }
46 if err != nil {
47 return nil, fmt.Errorf("read selector: %w", err)
48 }
49 } else {
50 data = []byte(input)
51 }
52
53 var sel types.Selector
54 if err := json.Unmarshal(data, &sel); err != nil {
55 return nil, fmt.Errorf("parse selector JSON: %w", err)
56 }
57 return &sel, nil
58}
59
60// parseJSONInput parses JSON from --from-json flag (inline, @file, or - for stdin).
61func parseJSONInput(input string, target any) error {

Callers 5

parseSelectorFunction · 0.85
negatives.goFile · 0.85
buildReportRequestFunction · 0.85
ad_rejections.goFile · 0.85
apps.goFile · 0.85

Calls 1

readStdinFunction · 0.85

Tested by

no test coverage detected