@@ -23,37 +23,47 @@ exports.main = function main(args, callback) {
2323 var lintDefault = "eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins" ;
2424 var argv = minimist ( args , {
2525 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"
3235 } ,
3336 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" ] ,
3538 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
5053 }
5154 } ) ;
5255
5356 var target = targets [ argv . target ] ,
5457 files = argv . _ ,
5558 paths = typeof argv . path === "string" ? [ argv . path ] : argv . path || [ ] ;
5659
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+
5767 // protobuf.js package directory contains additional, otherwise non-bundled google types
5868 paths . push ( path . relative ( process . cwd ( ) , path . join ( __dirname , ".." ) ) || "." ) ;
5969
@@ -110,15 +120,19 @@ exports.main = function main(args, callback) {
110120 " --no-delimited Does not generate delimited encode/decode functions." ,
111121 " --no-beautify Does not beautify generated code." ,
112122 " --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." ,
115126 "" ,
116127 "usage: " + chalk . bold . green ( "pbjs" ) + " [options] file1.proto file2.json ..." + chalk . gray ( " (or) " ) + "other | " + chalk . bold . green ( "pbjs" ) + " [options] -" ,
117128 ""
118129 ] . join ( "\n" ) ) ;
119130 return 1 ;
120131 }
121132
133+ if ( typeof argv [ "strict-long" ] === "boolean" )
134+ argv [ "force-long" ] = argv [ "strict-long" ] ;
135+
122136 // Resolve glob expressions
123137 for ( var i = 0 ; i < files . length ; ) {
124138 if ( glob . hasMagic ( files [ i ] ) ) {
0 commit comments