From 335496fc342d7e3978ecf4d2efbe736d5104c245 Mon Sep 17 00:00:00 2001 From: Ishmeet Date: Fri, 10 May 2024 16:23:05 +0530 Subject: [PATCH] Accept filepath as payload when argument starts with '@'. --- EXAMPLES.md | 2 +- TESTS.md | 75 +++-- doc/generated.usage.txt | 50 ++-- doc/template.README.md | 2 + src/flags.go | 17 +- test/payloads/invalid.txt | 1 + test/payloads/payload.json | 4 + test/payloads/payload.txt | 1 + test/results/help--X_GET-expected.txt | 50 ++-- test/results/help-expected.txt | 50 ++-- .../help-missing-curl--X_GET-expected.txt | 50 ++-- test/results/help-missing-curl-expected.txt | 50 ++-- .../help-missing-curl-no-curl-expected.txt | 50 ++-- test/results/help-no-curl-expected.txt | 50 ++-- test/results/missing-args--X_GET-expected.txt | 50 ++-- test/results/missing-args-expected.txt | 50 ++-- .../results/missing-args-no-curl-expected.txt | 50 ++-- .../missing-args-partial--X_GET-expected.txt | 50 ++-- .../results/missing-args-partial-expected.txt | 50 ++-- .../missing-args-partial-no-curl-expected.txt | 50 ++-- .../payload-file-not-found-expected.txt | 4 + test/results/payload-invalid-expected.txt | 4 + test/results/payload-json--v-expected.txt | 278 ++++++++++++++++++ test/results/payload-json-expected.txt | 7 + .../payload-json-relative-expected.txt | 7 + test/results/payload-txt-expected.txt | 12 + test/suite/test.sh | 6 +- test/suite/testcases.json | 38 +++ 28 files changed, 746 insertions(+), 362 deletions(-) create mode 100644 test/payloads/invalid.txt create mode 100644 test/payloads/payload.json create mode 100644 test/payloads/payload.txt create mode 100644 test/results/payload-file-not-found-expected.txt create mode 100644 test/results/payload-invalid-expected.txt create mode 100644 test/results/payload-json--v-expected.txt create mode 100644 test/results/payload-json-expected.txt create mode 100644 test/results/payload-json-relative-expected.txt create mode 100644 test/results/payload-txt-expected.txt diff --git a/EXAMPLES.md b/EXAMPLES.md index d12bcb33..c6a73feb 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -436,7 +436,7 @@ Total curl args: =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 20 Feb 2024 23:06:35 GMT +Date: Sat, 25 May 2024 22:15:22 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 35 diff --git a/TESTS.md b/TESTS.md index f8c3eebc..6e43260d 100644 --- a/TESTS.md +++ b/TESTS.md @@ -113,47 +113,43 @@ Running the tests might look like this: ``` $ ./test/suite/test.sh "$PWD" Populating cache... -Established Protobuf version 24.4 -Using cache... -Established go version 1.21.1 -Using cache... -Established Goreleaser version v1.21.2 -Using cache... -Established Latest released protoCURL version v1.7.0 -Variables: VERSION=1.8.0-rc-dev, VVERSION=v1.8.0-rc-dev, SNAPSHOT=true, BUILD_ARCH=amd64, PROTO_VERSION=24.4 +Established Protobuf version 27.0 +Populating cache... +Established go version 1.22.3 +Populating cache... +Established Goreleaser version v1.26.2 +Populating cache... +Established Latest released protoCURL version v1.8.1 +No protoc binaries for 27.0 found. Downloading... +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-aarch_64.zip ... +Extracting 27.0-linux-aarch_64 to 27.0-linux-arm64 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_32.zip ... +Extracting 27.0-linux-x86_32 to 27.0-linux-386 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip ... +Extracting 27.0-linux-x86_64 to 27.0-linux-amd64 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-osx-aarch_64.zip ... +Extracting 27.0-osx-aarch_64 to 27.0-darwin-arm64 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-osx-x86_64.zip ... +Extracting 27.0-osx-x86_64 to 27.0-darwin-amd64 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-win32.zip ... +Extracting 27.0-win32 to 27.0-windows-386 +Downloading https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-win64.zip ... +Extracting 27.0-win64 to 27.0-windows-amd64 +Done. +Variables: VERSION=1.9.0-rc-dev, VVERSION=v1.9.0-rc-dev, SNAPSHOT=true, BUILD_ARCH=amd64, PROTO_VERSION=27.0 Stopping server... Done. Building protocurl:latest ... -sha256:cc3be835f4e8a05cc0083bdfccc2c5c09854f4dc585bdedcb780d0bf582c5c9c +sha256:f4245bec7c1599da2cb44ef212dd066d95257935d58485ebfc1cebb761a4ab52 Done. Building test image variant of protocurl including additonal executables ... -[+] Building 0.3s (15/15) FINISHED docker:default - => [internal] load build definition from Dockerfile 0.0s - => => transferring dockerfile: 608B 0.0s - => [internal] load .dockerignore 0.0s - => => transferring context: 78B 0.0s - => [internal] load metadata for docker.io/library/debian:11-slim 0.2s - => [internal] load metadata for docker.io/library/protocurl:latest 0.0s - => [builder 1/2] FROM docker.io/library/debian:11-slim@sha256:c618be84fc82aa8ba203abbb07218410b0f5b3c7cb6b4e7248fda7785d4f9946 0.0s - => [final 1/8] FROM docker.io/library/protocurl:latest 0.0s - => CACHED [builder 2/2] RUN apt-get update && apt-get install -y inotify-tools procps 0.0s - => CACHED [final 2/8] COPY --from=builder /bin/* /bin/ 0.0s - => CACHED [final 3/8] COPY --from=builder /usr/bin/* /usr/bin/ 0.0s - => CACHED [final 4/8] COPY --from=builder /lib/*-linux-gnu /lib/x86_64-linux-gnu/ 0.0s - => CACHED [final 5/8] COPY --from=builder /lib/*-linux-gnu /lib/aarch_64-linux-gnu/ 0.0s - => CACHED [final 6/8] COPY --from=builder /usr/lib/*-linux-gnu /usr/lib/x86_64-linux-gnu/ 0.0s - => CACHED [final 7/8] COPY --from=builder /usr/lib/*-linux-gnu /usr/lib/aarch_64-linux-gnu/ 0.0s - => CACHED [final 8/8] COPY --from=builder /lib64*/ld-linux-*.so.2 /lib64/ 0.0s - => exporting to image 0.0s - => => exporting layers 0.0s - => => writing image sha256:1c56da99fb8a4e5cc3303bb9b4170254e6e962758c96fcf7718a6dfc08a3c999 0.0s - => => naming to docker.io/library/protocurl:latest-test 0.0s +sha256:d69bfe0bfd502082e3eb249eb1ee26f5ced21b4ec2ad71d74f8b748e5f000b1d Done. Starting server... Done. Waiting for server to become ready... +Waited 1 seconds already... Waited 2 seconds already... -Waited 3 seconds already... === Test server is ready === === Running ALL Tests === ✨✨✨ SUCCESS ✨✨✨ - wednesday-is-not-a-happy-day @@ -204,6 +200,12 @@ Waited 3 seconds already... ✨✨✨ SUCCESS ✨✨✨ - wednesday-is-not-a-happy-day-json ✨✨✨ SUCCESS ✨✨✨ - wednesday-is-not-a-happy-day-json-no-curl ✨✨✨ SUCCESS ✨✨✨ - wednesday-is-not-a-happy-day-json--X_GET +✨✨✨ SUCCESS ✨✨✨ - payload-json +✨✨✨ SUCCESS ✨✨✨ - payload-json--v +✨✨✨ SUCCESS ✨✨✨ - payload-json-relative +✨✨✨ SUCCESS ✨✨✨ - payload-txt +✨✨✨ SUCCESS ✨✨✨ - payload-invalid +✨✨✨ SUCCESS ✨✨✨ - payload-file-not-found ✨✨✨ SUCCESS ✨✨✨ - in-wrong ✨✨✨ SUCCESS ✨✨✨ - in-wrong--X_GET ✨✨✨ SUCCESS ✨✨✨ - out-wrong @@ -250,6 +252,9 @@ Waited 3 seconds already... ✨✨✨ SUCCESS ✨✨✨ - quiet-with-content ✨✨✨ SUCCESS ✨✨✨ - quiet-with-content-no-curl ✨✨✨ SUCCESS ✨✨✨ - quiet-with-content--X_GET +✨✨✨ SUCCESS ✨✨✨ - silent-with-content +✨✨✨ SUCCESS ✨✨✨ - silent-with-content-no-curl +✨✨✨ SUCCESS ✨✨✨ - silent-with-content--X_GET ✨✨✨ SUCCESS ✨✨✨ - display-binary-and-headers ✨✨✨ SUCCESS ✨✨✨ - display-binary-and-headers-no-curl ✨✨✨ SUCCESS ✨✨✨ - display-binary-and-headers--X_GET @@ -313,8 +318,16 @@ Waited 3 seconds already... ✨✨✨ SUCCESS ✨✨✨ - failure-simple-no-curl ✨✨✨ SUCCESS ✨✨✨ - failure-simple--X_GET ✨✨✨ SUCCESS ✨✨✨ - failure-simple-quiet +✨✨✨ SUCCESS ✨✨✨ - failure-simple-quiet--D +✨✨✨ SUCCESS ✨✨✨ - failure-simple-quiet--v ✨✨✨ SUCCESS ✨✨✨ - failure-simple-quiet-no-curl ✨✨✨ SUCCESS ✨✨✨ - failure-simple-quiet--X_GET +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent--D +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent--v +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent--q +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent-no-curl +✨✨✨ SUCCESS ✨✨✨ - failure-simple-silent--X_GET ✨✨✨ SUCCESS ✨✨✨ - missing-args ✨✨✨ SUCCESS ✨✨✨ - missing-args-no-curl ✨✨✨ SUCCESS ✨✨✨ - missing-args--X_GET diff --git a/doc/generated.usage.txt b/doc/generated.usage.txt index 5509a475..21ab3a5f 100644 --- a/doc/generated.usage.txt +++ b/doc/generated.usage.txt @@ -19,28 +19,28 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl diff --git a/doc/template.README.md b/doc/template.README.md index 423fc629..06f64dba 100644 --- a/doc/template.README.md +++ b/doc/template.README.md @@ -203,6 +203,8 @@ How to make a release: [RELEASE.md](RELEASE.md) - As for script utilities, one needs `bash`, `jq`, `zip`, `unzip` and `curl`. +Please make sure, that docker including the docker compose plugin is installed. The setup works with docker `v26.1.3` and docker compose `v2.27.0`, + Running the tests will download the protoc binaries on the first invocation automatically. For development the `generated-local.Dockerfile` (via [generate-local.Dockerfile.sh](dev/generate-local.Dockerfile.sh)) is used. diff --git a/src/flags.go b/src/flags.go index 14bf9a16..a98d9b03 100644 --- a/src/flags.go +++ b/src/flags.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os" "strings" ) @@ -85,9 +86,9 @@ func intialiseFlags() { "Mandatory: The url to send the request to") AssertSuccess(rootCmd.MarkFlagRequired("url")) - flags.StringVarP(&CurrentConfig.DataText, "data-text", "d", "", - "The payload data in Protobuf text format or JSON. "+ - "It is inferred from the input as JSON if the first token is a '{'. "+ + flags.StringVarP(&CurrentConfig.DataText, "data-text-or-file", "d", "", + "The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). "+ + "The string is inferred from the input as JSON if the first token is a '{'."+ "The format can be set explicitly via --in. Mandatory if request-type is provided."+ "See "+GithubRepositoryLink) @@ -170,6 +171,16 @@ func propagateFlags() { } } + if strings.HasPrefix(CurrentConfig.DataText, "@") { + filepath := CurrentConfig.DataText[1:] + if CurrentConfig.Verbose { + fmt.Printf("Input text will be read from file %s.\n", filepath) + } + file, err := os.ReadFile(filepath) + PanicOnError(err) + CurrentConfig.DataText = string(file) // assumes UTF-8 + } + if CurrentConfig.DataText != "" && CurrentConfig.RequestType == "" { PanicWithMessage("Non-empty data-body was provided, but no request type was given. Hence, encoding of data-body is not possible.") } diff --git a/test/payloads/invalid.txt b/test/payloads/invalid.txt new file mode 100644 index 00000000..08decfb3 --- /dev/null +++ b/test/payloads/invalid.txt @@ -0,0 +1 @@ +includeRe \ No newline at end of file diff --git a/test/payloads/payload.json b/test/payloads/payload.json new file mode 100644 index 00000000..1eb1b14a --- /dev/null +++ b/test/payloads/payload.json @@ -0,0 +1,4 @@ +{ + "includeReason":true, + "date": "2022-03-23T14:15:39Z" +} \ No newline at end of file diff --git a/test/payloads/payload.txt b/test/payloads/payload.txt new file mode 100644 index 00000000..392e17f2 --- /dev/null +++ b/test/payloads/payload.txt @@ -0,0 +1 @@ +includeReason: true, date: { seconds: 1648044939, nanos: 152000000 } \ No newline at end of file diff --git a/test/results/help--X_GET-expected.txt b/test/results/help--X_GET-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help--X_GET-expected.txt +++ b/test/results/help--X_GET-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/help-expected.txt b/test/results/help-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help-expected.txt +++ b/test/results/help-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/help-missing-curl--X_GET-expected.txt b/test/results/help-missing-curl--X_GET-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help-missing-curl--X_GET-expected.txt +++ b/test/results/help-missing-curl--X_GET-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/help-missing-curl-expected.txt b/test/results/help-missing-curl-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help-missing-curl-expected.txt +++ b/test/results/help-missing-curl-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/help-missing-curl-no-curl-expected.txt b/test/results/help-missing-curl-no-curl-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help-missing-curl-no-curl-expected.txt +++ b/test/results/help-missing-curl-no-curl-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/help-no-curl-expected.txt b/test/results/help-no-curl-expected.txt index f0eec85d..e705a073 100644 --- a/test/results/help-no-curl-expected.txt +++ b/test/results/help-no-curl-expected.txt @@ -20,30 +20,30 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl ######### STDERR ######### ######### EXIT 0 ######### diff --git a/test/results/missing-args--X_GET-expected.txt b/test/results/missing-args--X_GET-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args--X_GET-expected.txt +++ b/test/results/missing-args--X_GET-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-expected.txt b/test/results/missing-args-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args-expected.txt +++ b/test/results/missing-args-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-no-curl-expected.txt b/test/results/missing-args-no-curl-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args-no-curl-expected.txt +++ b/test/results/missing-args-no-curl-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial--X_GET-expected.txt b/test/results/missing-args-partial--X_GET-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args-partial--X_GET-expected.txt +++ b/test/results/missing-args-partial--X_GET-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-expected.txt b/test/results/missing-args-partial-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args-partial-expected.txt +++ b/test/results/missing-args-partial-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-no-curl-expected.txt b/test/results/missing-args-partial-no-curl-expected.txt index f7458530..ec40b840 100644 --- a/test/results/missing-args-partial-no-curl-expected.txt +++ b/test/results/missing-args-partial-no-curl-expected.txt @@ -18,31 +18,31 @@ Examples: protocurl -I my-protos -i package.path.Req -o package.path.Resp -u http://example.com/api -d "myField: true, otherField: 1337" Flags: - --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. - -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. - --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl - --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. - -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. - -h, --help help for protocurl - --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. - -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") - --no-curl Forces the use of the built-in internal http request instead of curl. - -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. - --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. - -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") - -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). - --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. - --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. - -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest - -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. - -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. - -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. - -u, --url string Mandatory: The url to send the request to - -v, --verbose Prints version and enables verbose output. Also activates -D. - --version version for protocurl + --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. + -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. + --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. + -d, --data-text-or-file string The payload data in Protobuf text format or JSON supplied as a string or a filepath (if first character is '@'). The string is inferred from the input as JSON if the first token is a '{'.The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl + --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. + -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. + -h, --help help for protocurl + --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. + -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on to curl optimistically. (default "POST") + --no-curl Forces the use of the built-in internal http request instead of curl. + -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. + --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. + -I, --proto-dir string Uses the specified directory to find the proto-file. (default "/proto") + -f, --proto-file string Uses the specified file path to find the Protobuf definition of the message types within 'proto-dir' (relative file path). + --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. + --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. + -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest + -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. + -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. + -s, --silent Suppresses all output on stdout. Overrides and deactivates -v, -D and -q. Errors are still printed to stderr. + -u, --url string Mandatory: The url to send the request to + -v, --verbose Prints version and enables verbose output. Also activates -D. + --version version for protocurl Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/payload-file-not-found-expected.txt b/test/results/payload-file-not-found-expected.txt new file mode 100644 index 00000000..1bfb6008 --- /dev/null +++ b/test/results/payload-file-not-found-expected.txt @@ -0,0 +1,4 @@ +######### STDOUT ######### +######### STDERR ######### +Error: open /payloads/does-not-exist: no such file or directory +######### EXIT 1 ######### diff --git a/test/results/payload-invalid-expected.txt b/test/results/payload-invalid-expected.txt new file mode 100644 index 00000000..f74726f7 --- /dev/null +++ b/test/results/payload-invalid-expected.txt @@ -0,0 +1,4 @@ +######### STDOUT ######### +######### STDERR ######### +Error: proto: (line 1:1): unknown field: includeRe +######### EXIT 1 ######### diff --git a/test/results/payload-json--v-expected.txt b/test/results/payload-json--v-expected.txt new file mode 100644 index 00000000..ce1ebab7 --- /dev/null +++ b/test/results/payload-json--v-expected.txt @@ -0,0 +1,278 @@ +######### STDOUT ######### +Input text will be read from file /payloads/payload.json. +Inferred input text type as json. +Infering proto files (-F), since -f was not provided. +protocurl , build , https://github.com/qaware/protocurl +Adding default header argument to request headers : [Content-Type: application/x-protobuf] +Invoked with following default & parsed arguments: +{ + "ProtoFilesDir": "/proto", + "ProtoInputFilePath": "", + "RequestType": "..HappyDayRequest", + "ResponseType": "..HappyDayResponse", + "Url": "http://localhost:8080/happy-day/verify", + "Method": "POST", + "DataText": "{\n \"includeReason\":true,\n \"date\": \"2022-03-23T14:15:39Z\"\n}", + "InTextType": "json", + "OutTextType": "json", + "DecodeRawResponse": false, + "DisplayBinaryAndHttp": true, + "NoDefaultHeaders": false, + "RequestHeaders": [ + "Content-Type: application/x-protobuf" + ], + "CustomCurlPath": "", + "AdditionalCurlArgs": "", + "Verbose": true, + "ShowOutputOnly": false, + "SilentMode": false, + "ForceNoCurl": false, + "ForceCurl": false, + "GlobalProtoc": false, + "CustomProtocPath": "", + "InferProtoFiles": true +} +Found bundled protoc at /protocurl/protocurl-internal/bin/protoc +Using google protobuf include: /protocurl/protocurl-internal/include +Converting all files in /proto to a FileDescriptorSet. +Found .proto: happyday.proto +=========================== .proto descriptor =========================== +file: { + name: "google/protobuf/timestamp.proto" + package: "google.protobuf" + message_type: { + name: "Timestamp" + field: { + name: "seconds" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "seconds" + } + field: { + name: "nanos" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "nanos" + } + } + options: { + java_package: "com.google.protobuf" + java_outer_classname: "TimestampProto" + java_multiple_files: true + go_package: "google.golang.org/protobuf/types/known/timestamppb" + cc_enable_arenas: true + objc_class_prefix: "GPB" + csharp_namespace: "Google.Protobuf.WellKnownTypes" + } + syntax: "proto3" +} +file: { + name: "happyday.proto" + package: "happyday" + dependency: "google/protobuf/timestamp.proto" + message_type: { + name: "HappyDayRequest" + field: { + name: "date" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".google.protobuf.Timestamp" + json_name: "date" + } + field: { + name: "includeReason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "includeReason" + } + field: { + name: "double" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + json_name: "double" + } + field: { + name: "int32" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT32 + json_name: "int32" + } + field: { + name: "int64" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT64 + json_name: "int64" + } + field: { + name: "string" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "string" + } + field: { + name: "bytes" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BYTES + json_name: "bytes" + } + field: { + name: "fooEnum" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + json_name: "fooEnum" + } + field: { + name: "misc" + number: 9 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".happyday.MiscInfo" + json_name: "misc" + } + field: { + name: "float" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + json_name: "float" + } + field: { + name: "NonCamel_case_FieldName" + number: 11 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "NonCamelCaseFieldName" + } + } + message_type: { + name: "HappyDayResponse" + field: { + name: "isHappyDay" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_BOOL + json_name: "isHappyDay" + } + field: { + name: "reason" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "reason" + } + field: { + name: "formattedDate" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "formattedDate" + } + field: { + name: "err" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_STRING + json_name: "err" + } + } + message_type: { + name: "MiscInfo" + field: { + name: "weatherOfPastFewDays" + number: 1 + label: LABEL_REPEATED + type: TYPE_STRING + json_name: "weatherOfPastFewDays" + } + field: { + name: "fooString" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + json_name: "fooString" + } + field: { + name: "fooEnum" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".happyday.Foo" + oneof_index: 0 + json_name: "fooEnum" + } + oneof_decl: { + name: "alternative" + } + } + enum_type: { + name: "Foo" + value: { + name: "BAR" + number: 0 + } + value: { + name: "BAZ" + number: 1 + } + value: { + name: "FAZ" + number: 2 + } + } + syntax: "proto3" +} +Searching for message with base name: HappyDayRequest +Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest] +Searching for message with base name: HappyDayRequest +Resolved message package-paths for name HappyDayRequest: [happyday.HappyDayRequest] +=========================== POST Request JSON =========================== >>> +{"date":"2022-03-23T14:15:39Z","includeReason":true} +=========================== POST Request Binary =========================== >>> +00000000 0a 06 08 8b d7 ec 91 06 10 01 |..........| +Found curl: /usr/bin/curl +Invoking curl http request. +Understood additional curl args: [] +Total curl args: + -s + -X + POST + --output + + --dump-header + + --data-binary + @ + -H + Content-Type: application/x-protobuf + http://localhost:8080/happy-day/verify +=========================== POST Response Headers =========================== <<< +HTTP/1.1 200 OK +Content-Type: application/x-protobuf +Date: Sat, 25 May 2024 21:57:59 GMT +Connection: keep-alive +Keep-Alive: timeout=5 +Content-Length: 68 +=========================== POST Response Binary =========================== <<< +00000000 08 00 12 1f 54 6f 75 67 68 20 6c 75 63 6b 20 6f |....Tough luck o| +00000010 6e 20 57 65 64 6e 65 73 64 61 79 2e 2e 2e 20 f0 |n Wednesday... .| +00000020 9f 98 95 1a 1d 57 65 64 2c 20 32 33 20 4d 61 72 |.....Wed, 23 Mar| +00000030 20 32 30 32 32 20 31 34 3a 31 35 3a 33 39 20 47 | 2022 14:15:39 G| +00000040 4d 54 22 00 |MT".| +Searching for message with base name: HappyDayResponse +Resolved message package-paths for name HappyDayResponse: [happyday.HappyDayResponse] +=========================== POST Response JSON =========================== <<< +{"reason":"Tough luck on Wednesday... 😕","formattedDate":"Wed, 23 Mar 2022 14:15:39 GMT"} +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/payload-json-expected.txt b/test/results/payload-json-expected.txt new file mode 100644 index 00000000..1b627674 --- /dev/null +++ b/test/results/payload-json-expected.txt @@ -0,0 +1,7 @@ +######### STDOUT ######### +=========================== POST Request JSON =========================== >>> +{"date":"2022-03-23T14:15:39Z","includeReason":true} +=========================== POST Response JSON =========================== <<< +{"reason":"Tough luck on Wednesday... 😕","formattedDate":"Wed, 23 Mar 2022 14:15:39 GMT"} +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/payload-json-relative-expected.txt b/test/results/payload-json-relative-expected.txt new file mode 100644 index 00000000..1b627674 --- /dev/null +++ b/test/results/payload-json-relative-expected.txt @@ -0,0 +1,7 @@ +######### STDOUT ######### +=========================== POST Request JSON =========================== >>> +{"date":"2022-03-23T14:15:39Z","includeReason":true} +=========================== POST Response JSON =========================== <<< +{"reason":"Tough luck on Wednesday... 😕","formattedDate":"Wed, 23 Mar 2022 14:15:39 GMT"} +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/results/payload-txt-expected.txt b/test/results/payload-txt-expected.txt new file mode 100644 index 00000000..7f419a9f --- /dev/null +++ b/test/results/payload-txt-expected.txt @@ -0,0 +1,12 @@ +######### STDOUT ######### +=========================== POST Request Text =========================== >>> +date: { + seconds: 1648044939 + nanos: 152000000 +} +includeReason: true +=========================== POST Response Text =========================== <<< +reason: "Tough luck on Wednesday... 😕" +formattedDate: "Wed, 23 Mar 2022 14:15:39 GMT" +######### STDERR ######### +######### EXIT 0 ######### diff --git a/test/suite/test.sh b/test/suite/test.sh index afdc74a0..ce09687e 100755 --- a/test/suite/test.sh +++ b/test/suite/test.sh @@ -11,7 +11,7 @@ fi WORKING_DIR="$1" -export RUN_CLIENT="docker run --rm -v $WORKING_DIR/test/proto:/proto --network host" +export RUN_CLIENT="docker run --rm -v $WORKING_DIR/test/proto:/proto -v $WORKING_DIR/test/payloads:/payloads --network host" export SHOW_LOGS="docker logs" @@ -99,7 +99,9 @@ runAllTests() { # Convert each element in the JSON to the corresponding call of the testSingleRequest function. # Simply look at the produced run-testcases.sh file to see what it looks like. CONVERT_TESTCASE_TO_SINGLE_TEST_INVOCATION=".[] | \"testSingleSpec \(.filename|@sh) \(.args|join(\" \")|@sh) \(.beforeTestBash // \"\"|@sh) \(.afterTestBash // \"\"|@sh) \((.rerunwithArgForEachElement // [])|@sh)\"" - cat test/suite/testcases.json | jq -r "$CONVERT_TESTCASE_TO_SINGLE_TEST_INVOCATION" >./test/suite/run-testcases.sh + cat test/suite/testcases.json \ + | jq -r "$CONVERT_TESTCASE_TO_SINGLE_TEST_INVOCATION" \ + >./test/suite/run-testcases.sh export -f testSingleSpec export -f testSingleRequest diff --git a/test/suite/testcases.json b/test/suite/testcases.json index e665fa25..8e32ca53 100644 --- a/test/suite/testcases.json +++ b/test/suite/testcases.json @@ -212,6 +212,44 @@ "-X GET" ] }, + { + "filename": "payload-json", + "args": [ + "-i ..HappyDayRequest -o ..HappyDayResponse -u http://localhost:8080/happy-day/verify", + "-d @/payloads/payload.json" + ], + "rerunwithArgForEachElement": [ + "-v" + ] + }, + { + "filename": "payload-json-relative", + "args": [ + "-i ..HappyDayRequest -o ..HappyDayResponse -u http://localhost:8080/happy-day/verify", + "-d @../payloads/payload.json" + ] + }, + { + "filename": "payload-txt", + "args": [ + "-i ..HappyDayRequest -o ..HappyDayResponse -u http://localhost:8080/happy-day/verify", + "-d @/payloads/payload.txt" + ] + }, + { + "filename": "payload-invalid", + "args": [ + "-i ..HappyDayRequest -o ..HappyDayResponse -u http://localhost:8080/happy-day/verify", + "-d @/payloads/invalid.txt" + ] + }, + { + "filename": "payload-file-not-found", + "args": [ + "-i ..HappyDayRequest -o ..HappyDayResponse -u http://localhost:8080/happy-day/verify", + "-d @/payloads/does-not-exist" + ] + }, { "filename": "in-wrong", "args": [