Skip to content

Commit

Permalink
feat: add --no-service option for pbjs static target (#1577)
Browse files Browse the repository at this point in the history
This option skips generation of service clients.

Co-authored-by: Alexander Fenster <fenster@google.com>
  • Loading branch information
mdouglass and alexander-fenster committed Apr 14, 2021
1 parent 40a6b35 commit d01394a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/README.md
Expand Up @@ -63,6 +63,7 @@ Translates between file formats and generates static code.
--no-delimited Does not generate delimited encode/decode functions.
--no-beautify Does not beautify generated code.
--no-comments Does not output any JSDoc comments.
--no-service Does not output service classes.
--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.
Expand Down
4 changes: 3 additions & 1 deletion cli/pbjs.js
Expand Up @@ -41,7 +41,7 @@ exports.main = function main(args, callback) {
"force-message": "strict-message"
},
string: [ "target", "out", "path", "wrap", "dependency", "root", "lint" ],
boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ],
boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "service", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ],
default: {
target: "json",
create: true,
Expand All @@ -52,6 +52,7 @@ exports.main = function main(args, callback) {
delimited: true,
beautify: true,
comments: true,
service: true,
es6: null,
lint: lintDefault,
"keep-case": false,
Expand Down Expand Up @@ -132,6 +133,7 @@ exports.main = function main(args, callback) {
" --no-delimited Does not generate delimited encode/decode functions.",
" --no-beautify Does not beautify generated code.",
" --no-comments Does not output any JSDoc comments.",
" --no-service Does not output service classes.",
"",
" --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.",
Expand Down
4 changes: 4 additions & 0 deletions cli/targets/static.js
Expand Up @@ -109,6 +109,10 @@ function aOrAn(name) {
function buildNamespace(ref, ns) {
if (!ns)
return;

if (ns instanceof Service && !config.service)
return;

if (ns.name !== "") {
push("");
if (!ref && config.es6)
Expand Down

0 comments on commit d01394a

Please sign in to comment.