@@ -23,37 +23,47 @@ exports.main = function main(args, callback) {
23
23
var lintDefault = "eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins" ;
24
24
var argv = minimist ( args , {
25
25
alias : {
26
- target : "t" ,
27
- out : "o" ,
28
- path : "p" ,
29
- wrap : "w" ,
30
- root : "r" ,
31
- lint : "l"
26
+ target : "t" ,
27
+ out : "o" ,
28
+ path : "p" ,
29
+ wrap : "w" ,
30
+ root : "r" ,
31
+ lint : "l" ,
32
+ // backward compatibility:
33
+ "force-long" : "strict-long" ,
34
+ "force-message" : "strict-message"
32
35
} ,
33
36
string : [ "target" , "out" , "path" , "wrap" , "root" , "lint" ] ,
34
- boolean : [ "keep-case" , " create", "encode" , "decode" , "verify" , "convert" , "delimited" , "beautify" , "comments" , "es6" , "sparse" , "strict- long" , "strict -message" ] ,
37
+ boolean : [ "create" , "encode" , "decode" , "verify" , "convert" , "delimited" , "beautify" , "comments" , "es6" , "sparse" , "keep-case" , "force- long", "force -message" ] ,
35
38
default : {
36
- target : "json" ,
37
- create : true ,
38
- encode : true ,
39
- decode : true ,
40
- verify : true ,
41
- convert : true ,
42
- delimited : true ,
43
- beautify : true ,
44
- comments : true ,
45
- es6 : null ,
46
- lint : lintDefault ,
47
- "keep-case" : false ,
48
- "strict -long" : false ,
49
- "strict -message" : false
39
+ target : "json" ,
40
+ create : true ,
41
+ encode : true ,
42
+ decode : true ,
43
+ verify : true ,
44
+ convert : true ,
45
+ delimited : true ,
46
+ beautify : true ,
47
+ comments : true ,
48
+ es6 : null ,
49
+ lint : lintDefault ,
50
+ "keep-case" : false ,
51
+ "force -long" : false ,
52
+ "force -message" : false
50
53
}
51
54
} ) ;
52
55
53
56
var target = targets [ argv . target ] ,
54
57
files = argv . _ ,
55
58
paths = typeof argv . path === "string" ? [ argv . path ] : argv . path || [ ] ;
56
59
60
+ // alias hyphen args in camel case
61
+ Object . keys ( argv ) . forEach ( function ( key ) {
62
+ var camelKey = key . replace ( / \- ( [ a - z ] ) / g, function ( $0 , $1 ) { return $1 . toUpperCase ( ) ; } ) ;
63
+ if ( camelKey !== key )
64
+ argv [ camelKey ] = argv [ key ] ;
65
+ } ) ;
66
+
57
67
// protobuf.js package directory contains additional, otherwise non-bundled google types
58
68
paths . push ( path . relative ( process . cwd ( ) , path . join ( __dirname , ".." ) ) || "." ) ;
59
69
@@ -110,15 +120,19 @@ exports.main = function main(args, callback) {
110
120
" --no-delimited Does not generate delimited encode/decode functions." ,
111
121
" --no-beautify Does not beautify generated code." ,
112
122
" --no-comments Does not output any JSDoc comments." ,
113
- " --strict-long Strictly references 'Long' for s-/u-/int64 and s-/fixed64 types." ,
114
- " --strict-message Strictly references message types instead of typedefs." ,
123
+ "" ,
124
+ " --force-long Enfores the use of 'Long' for s-/u-/int64 and s-/fixed64 fields." ,
125
+ " --force-message Enfores the use of runtime messages instead of plain objects." ,
115
126
"" ,
116
127
"usage: " + chalk . bold . green ( "pbjs" ) + " [options] file1.proto file2.json ..." + chalk . gray ( " (or) " ) + "other | " + chalk . bold . green ( "pbjs" ) + " [options] -" ,
117
128
""
118
129
] . join ( "\n" ) ) ;
119
130
return 1 ;
120
131
}
121
132
133
+ if ( typeof argv [ "strict-long" ] === "boolean" )
134
+ argv [ "force-long" ] = argv [ "strict-long" ] ;
135
+
122
136
// Resolve glob expressions
123
137
for ( var i = 0 ; i < files . length ; ) {
124
138
if ( glob . hasMagic ( files [ i ] ) ) {
0 commit comments