diff --git a/cli/README.md b/cli/README.md index 25a0cbbb1..e7f189007 100644 --- a/cli/README.md +++ b/cli/README.md @@ -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. diff --git a/cli/pbjs.js b/cli/pbjs.js index 8766e4f43..6b69397f3 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" ], - 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, @@ -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, @@ -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.", diff --git a/cli/targets/static.js b/cli/targets/static.js index 7d5c706a4..f72734a82 100644 --- a/cli/targets/static.js +++ b/cli/targets/static.js @@ -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)