Skip to content

Commit

Permalink
Add default values to generator usage info
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Apr 1, 2021
1 parent 0aa99dd commit 65f1eb4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
51 changes: 27 additions & 24 deletions packages/proto-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions packages/proto-loader/bin/proto-loader-gen-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 65f1eb4

Please sign in to comment.