Skip to content

Commit 1a6fdc9

Browse files
committed
Added ParseOptions to protobuf.parse and --keep-case for .proto sources to pbjs, see #564
1 parent 4531d75 commit 1a6fdc9

File tree

14 files changed

+132
-46
lines changed

14 files changed

+132
-46
lines changed

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
This license applies to all parts of protobuf.js except those files including
2+
or referencing a different license.
13

24
Apache License
35
Version 2.0, January 2004

cli/pbjs.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ exports.main = function(args, callback) {
2626
root : "r"
2727
},
2828
string: [ "target", "out", "path", "wrap", "root" ],
29+
boolean: [ "keep-case", "encode", "decode", "verify", "delimited" ],
2930
default: {
30-
target: "json"
31+
target: "json",
32+
encode: true,
33+
decode: true,
34+
verify: true,
35+
delimited: true
3136
}
3237
});
3338

@@ -55,15 +60,21 @@ exports.main = function(args, callback) {
5560
"",
5661
" -o, --out Saves to a file instead of writing to stdout.",
5762
"",
58-
" -w, --wrap Specifies the wrapper to use for *-module targets. Also accepts a path.",
63+
" Module targets only:",
64+
"",
65+
" -w, --wrap Specifies the wrapper to use. Also accepts a path to require a custom wrapper.",
5966
"",
6067
" default Default wrapper supporting both CommonJS and AMD",
6168
" commonjs CommonJS only wrapper",
6269
" amd AMD only wrapper",
6370
"",
64-
" -r, --root Specifies an alternative protobuf.roots name for *-module targets.",
71+
" -r, --root Specifies an alternative protobuf.roots name.",
72+
"",
73+
" Proto sources only:",
74+
"",
75+
" --keep-case Keeps field casing instead of converting to camel case (not recommended).",
6576
"",
66-
" Static code generation only:",
77+
" Static targets only:",
6778
"",
6879
" --no-encode Does not generate encode functions.",
6980
" --no-decode Does not generate decode functions.",
@@ -104,7 +115,11 @@ exports.main = function(args, callback) {
104115
return filepath;
105116
};
106117

107-
root.load(files, function(err) {
118+
var parseOptions = {
119+
"keepCase": argv["keep-case"] || false
120+
};
121+
122+
root.load(files, parseOptions, function(err) {
108123
if (err) {
109124
if (callback)
110125
return callback(err);

cli/targets/static.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function buildType(ref, type) {
271271
push("});");
272272
});
273273

274-
if (config.encode !== false) {
274+
if (config.encode) {
275275

276276
// #encode
277277
push("");
@@ -287,7 +287,7 @@ function buildType(ref, type) {
287287
util : "$protobuf.util"
288288
});
289289

290-
if (config.delimited !== false) {
290+
if (config.delimited) {
291291

292292
// #encodeDelimited
293293
push("");
@@ -307,7 +307,7 @@ function buildType(ref, type) {
307307

308308
}
309309

310-
if (config.decode !== false) {
310+
if (config.decode) {
311311

312312
// #decode
313313
push("");
@@ -323,7 +323,7 @@ function buildType(ref, type) {
323323
util : "$protobuf.util"
324324
});
325325

326-
if (config.delimited !== false) {
326+
if (config.delimited) {
327327

328328
// #decodeDelimited
329329
push("");
@@ -342,7 +342,7 @@ function buildType(ref, type) {
342342
}
343343
}
344344

345-
if (config.verify !== false) {
345+
if (config.verify) {
346346

347347
// #verify
348348
push("");

dist/protobuf.js

Lines changed: 40 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

45 Bytes
Binary file not shown.

dist/protobuf.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runtime/protobuf.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)