MCPcopy Create free account
hub / github.com/cli/cli / validateName

Function validateName

script/ghmock/set.go:135–150  ·  view source on GitHub ↗

validateName checks that a request name looks like "graphql Operation" or "METHOD /path".

(name string)

Source from the content-addressed store, hash-verified

133// validateName checks that a request name looks like "graphql Operation" or
134// "METHOD /path".
135func validateName(name string) error {
136 method, target, ok := strings.Cut(name, " ")
137 if !ok || target == "" || strings.ContainsAny(target, " \t") {
138 return fmt.Errorf("request name %q must look like \"GET /repos/octo/hello\" or \"graphql IssueByNumber\"", name)
139 }
140 if method == "graphql" {
141 return nil
142 }
143 if strings.ToUpper(method) != method || strings.Trim(method, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") != "" {
144 return fmt.Errorf("request name %q must start with an uppercase HTTP method or \"graphql\"", name)
145 }
146 if !strings.Contains(target, "/") {
147 return fmt.Errorf("request name %q must include a path, such as /repos/octo/hello", name)
148 }
149 return nil
150}
151
152func cmdSet(args []string, stdout, stderr io.Writer) error {
153 opts, err := parseSetArgs(args)

Callers 3

parseSetArgsFunction · 0.70
parseScaffoldArgsFunction · 0.70
parseSchemaArgsFunction · 0.70

Calls 2

ContainsMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected