From bee997d5e86a85a395b76a6551570e8b756ce8d1 Mon Sep 17 00:00:00 2001 From: Martin Traverse Date: Fri, 26 Jul 2024 15:43:14 +0100 Subject: [PATCH] Update PBJS and README for new --null-semantics flag --- cli/README.md | 4 +++- cli/pbjs.js | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cli/README.md b/cli/README.md index 1a24fa4df..7fb6da453 100644 --- a/cli/README.md +++ b/cli/README.md @@ -68,7 +68,9 @@ Translates between file formats and generates static code. --force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields. --force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields. --force-message Enforces the use of message instances instead of plain objects. - --force-optional Enforces nullable types for fields marked as optional (proto2 and proto3) + + --null-semantics Make nullable fields match protobuf semantics (including the optional keyword) + --null-defaults Default value for optional fields is null instead of zero value (no effect if --null-semantics is specified) usage: pbjs [options] file1.proto file2.json ... (or pipe) other | pbjs [options] - ``` diff --git a/cli/pbjs.js b/cli/pbjs.js index c8d9a8a1d..1d238a090 100644 --- a/cli/pbjs.js +++ b/cli/pbjs.js @@ -41,7 +41,7 @@ exports.main = function main(args, callback) { "force-message": "strict-message" }, string: [ "target", "out", "path", "wrap", "dependency", "root", "lint", "filter" ], - boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "typeurl", "beautify", "comments", "service", "es6", "sparse", "keep-case", "alt-comment", "force-long", "force-number", "force-enum-string", "force-message", "force-optional", "null-defaults"], + boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "typeurl", "beautify", "comments", "service", "es6", "sparse", "keep-case", "alt-comment", "force-long", "force-number", "force-enum-string", "force-message", "null-semantics", "null-defaults"], default: { target: "json", create: true, @@ -62,7 +62,7 @@ exports.main = function main(args, callback) { "force-number": false, "force-enum-string": false, "force-message": false, - "force-optional": false, + "null-semantics": false, "null-defaults": false } }); @@ -147,9 +147,9 @@ exports.main = function main(args, callback) { " --force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.", " --force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.", " --force-message Enforces the use of message instances instead of plain objects.", - " --force-optional Enforces nullable types for fields marked as optional (proto2 and proto3)", "", - " --null-defaults Default value for optional fields is null instead of zero value (deprecated, use --force-optional instead)", + " --null-semantics Make nullable fields match protobuf semantics (including the optional keyword)", + " --null-defaults Default value for optional fields is null instead of zero value (no effect if --null-semantics is specified)", "", "usage: " + chalk.bold.green("pbjs") + " [options] file1.proto file2.json ..." + chalk.gray(" (or pipe) ") + "other | " + chalk.bold.green("pbjs") + " [options] -", ""