diff --git a/commands/api.go b/commands/api.go index d9a08d4a..d1be8625 100644 --- a/commands/api.go +++ b/commands/api.go @@ -16,7 +16,7 @@ import ( var cmdApi = &Command{ Run: apiCommand, - Usage: "api [-t] [-X ] [--cache ] [-F ]", + Usage: "api [-it] [-X ] [-H
] [--cache ] [-F |--input ]", Long: `Low-level GitHub API request interface. ## Options: @@ -28,9 +28,9 @@ var cmdApi = &Command{ Use '-XGET' to force serializing fields into the query string for the GET request instead of JSON body of the POST request. - -F, --field - Send data in 'KEY=VALUE' format. The part has some magic handling; - see '--raw-field' for passing arbitrary strings. + -F, --field = + Data to serialize with the request. has some magic handling; use + '--raw-field' for sending arbitrary string values. If starts with "@", the rest of the value is interpreted as a filename to read the value from. Use "@-" to read from standard input. @@ -38,12 +38,16 @@ var cmdApi = &Command{ If is "true", "false", "null", or looks like a number, an appropriate JSON type is used instead of a string. + It is not possible to serialize as a nested JSON array or hash. + Instead, construct the request payload externally and pass it via + '--input'. + Unless '-XGET' was used, all fields are sent serialized as JSON within the request body. When is "graphql", all fields other than "query" are grouped under "variables". See - -f, --raw-field + -f, --raw-field = Same as '--field', except that it allows values starting with "@", literal strings "true", "false", and "null", as well as strings that look like numbers. @@ -52,8 +56,8 @@ var cmdApi = &Command{ The filename to read the raw request body from. Use "-" to read from standard input. Use this when you want to manually construct the request payload. - -H, --header - An HTTP request header in 'KEY: VALUE' format. + -H, --header : + Set an HTTP request header. -i, --include Include HTTP response headers in the output. diff --git a/utils/args_parser.go b/utils/args_parser.go index 8c9ff2d8..2bf1474b 100644 --- a/utils/args_parser.go +++ b/utils/args_parser.go @@ -192,7 +192,7 @@ func NewArgsParser() *ArgsParser { func NewArgsParserWithUsage(usage string) *ArgsParser { p := NewArgsParser() - f := `(-[a-zA-Z0-9@^]|--[a-z][a-z0-9-]+)(?:[ =]?)?` + f := `(-[a-zA-Z0-9@^]|--[a-z][a-z0-9-]+)(?:[ =]([a-zA-Z_<>:=-]+))?` re := regexp.MustCompile(fmt.Sprintf(`(?m)^\s*%s(?:,\s*%s)?$`, f, f)) for _, match := range re.FindAllStringSubmatch(usage, -1) { n1 := match[1]