Skip to content

Commit d01394a

Browse files
feat: add --no-service option for pbjs static target (#1577)
This option skips generation of service clients. Co-authored-by: Alexander Fenster <[email protected]>
1 parent 40a6b35 commit d01394a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

cli/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Translates between file formats and generates static code.
6363
--no-delimited Does not generate delimited encode/decode functions.
6464
--no-beautify Does not beautify generated code.
6565
--no-comments Does not output any JSDoc comments.
66+
--no-service Does not output service classes.
6667
6768
--force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.
6869
--force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.

cli/pbjs.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ exports.main = function main(args, callback) {
4141
"force-message": "strict-message"
4242
},
4343
string: [ "target", "out", "path", "wrap", "dependency", "root", "lint" ],
44-
boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ],
44+
boolean: [ "create", "encode", "decode", "verify", "convert", "delimited", "beautify", "comments", "service", "es6", "sparse", "keep-case", "force-long", "force-number", "force-enum-string", "force-message" ],
4545
default: {
4646
target: "json",
4747
create: true,
@@ -52,6 +52,7 @@ exports.main = function main(args, callback) {
5252
delimited: true,
5353
beautify: true,
5454
comments: true,
55+
service: true,
5556
es6: null,
5657
lint: lintDefault,
5758
"keep-case": false,
@@ -132,6 +133,7 @@ exports.main = function main(args, callback) {
132133
" --no-delimited Does not generate delimited encode/decode functions.",
133134
" --no-beautify Does not beautify generated code.",
134135
" --no-comments Does not output any JSDoc comments.",
136+
" --no-service Does not output service classes.",
135137
"",
136138
" --force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.",
137139
" --force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.",

cli/targets/static.js

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ function aOrAn(name) {
109109
function buildNamespace(ref, ns) {
110110
if (!ns)
111111
return;
112+
113+
if (ns instanceof Service && !config.service)
114+
return;
115+
112116
if (ns.name !== "") {
113117
push("");
114118
if (!ref && config.es6)

0 commit comments

Comments
 (0)