From 65f1eb4a2983e2c38d89787be5280bc4a2a6d181 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Thu, 1 Apr 2021 11:53:30 -0700 Subject: [PATCH] Add default values to generator usage info --- packages/proto-loader/README.md | 51 ++++++++++--------- .../bin/proto-loader-gen-types.ts | 10 ++++ 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/packages/proto-loader/README.md b/packages/proto-loader/README.md index 198f9d2b..123fad11 100644 --- a/packages/proto-loader/README.md +++ b/packages/proto-loader/README.md @@ -61,30 +61,33 @@ The `proto-loader-gen-types` script distributed with this package can be used to proto-loader-gen-types.js [options] filenames... Options: - --help Show help [boolean] - --version Show version number [boolean] - --keepCase Preserve the case of field names [boolean] - --longs The type that should be used to output 64 bit integer - values. Can be String, Number [string] - --enums The type that should be used to output enum fields. Can be - String [string] - --bytes The type that should be used to output bytes fields. Can be - String, Array [string] - --defaults Output default values for omitted fields [boolean] - --arrays Output default values for omitted repeated fields even if - --defaults is not set [boolean] - --objects Output default values for omitted message fields even if - --defaults is not set [boolean] - --oneofs Output virtual oneof fields set to the present field's name - [boolean] - --json Represent Infinity and NaN as strings in float fields. Also - decode google.protobuf.Any automatically [boolean] - --includeComments Generate doc comments from comments in the original files - [boolean] - --includeDirs, -I Directories to search for included files [array] - --outDir, -O Directory in which to output files [string] [required] - --grpcLib The gRPC implementation library that these types will be - used with [string] [required] + --help Show help [boolean] + --version Show version number [boolean] + --keepCase Preserve the case of field names + [boolean] [default: false] + --longs The type that should be used to output 64 bit integer + values. Can be String, Number[string] [default: "Long"] + --enums The type that should be used to output enum fields. Can + be String [string] [default: "number"] + --bytes The type that should be used to output bytes fields. + Can be String, Array [string] [default: "Buffer"] + --defaults Output default values for omitted fields + [boolean] [default: false] + --arrays Output default values for omitted repeated fields even + if --defaults is not set [boolean] [default: false] + --objects Output default values for omitted message fields even + if --defaults is not set [boolean] [default: false] + --oneofs Output virtual oneof fields set to the present field's + name [boolean] [default: false] + --json Represent Infinity and NaN as strings in float fields. + Also decode google.protobuf.Any automatically + [boolean] [default: false] + --includeComments Generate doc comments from comments in the original + files [boolean] [default: false] + -I, --includeDirs Directories to search for included files [array] + -O, --outDir Directory in which to output files [string] [required] + --grpcLib The gRPC implementation library that these types will + be used with [string] [required] ``` ### Example Usage diff --git a/packages/proto-loader/bin/proto-loader-gen-types.ts b/packages/proto-loader/bin/proto-loader-gen-types.ts index 441f26fd..c11befee 100644 --- a/packages/proto-loader/bin/proto-loader-gen-types.ts +++ b/packages/proto-loader/bin/proto-loader-gen-types.ts @@ -695,6 +695,16 @@ function runScript() { .array('includeDirs') .boolean(['keepCase', 'defaults', 'arrays', 'objects', 'oneofs', 'json', 'verbose', 'includeComments']) .string(['longs', 'enums', 'bytes']) + .default('keepCase', false) + .default('defaults', false) + .default('arrays', false) + .default('objects', false) + .default('oneofs', false) + .default('json', false) + .default('includeComments', false) + .default('longs', 'Long') + .default('enums', 'number') + .default('bytes', 'Buffer') .coerce('longs', value => { switch (value) { case 'String': return String;