@@ -513,9 +513,10 @@ function jsonToGov2(json, options = {}) {
513
513
if ( typeof module != 'undefined' ) {
514
514
if ( ! module . parent ) {
515
515
let filename = null
516
+ let options = { }
516
517
517
- function jsonToGoWithErrorHandling ( json ) {
518
- const output = jsonToGov2 ( json )
518
+ function jsonToGoWithErrorHandling ( json , options ) {
519
+ const output = jsonToGov2 ( json , options )
519
520
if ( output . error ) {
520
521
console . error ( output . error )
521
522
process . exitCode = 1
@@ -532,11 +533,32 @@ if (typeof module != 'undefined') {
532
533
return
533
534
}
534
535
535
- const argument = val . replace ( / - / g, '' )
536
- switch ( argument ) {
536
+ let argument = {
537
+ arg : val . split ( "=" ) [ 0 ] . replace ( / ^ - + / , '' ) ,
538
+ value : val . split ( "=" ) [ 1 ] || true ,
539
+ }
540
+
541
+ if ( argument . arg . startsWith ( "no-" ) ) {
542
+ argument . arg = argument . arg . replace ( / ^ n o - / , '' )
543
+ argument . value = ! argument . value
544
+ }
545
+
546
+ switch ( argument . arg ) {
537
547
case "big" :
538
548
console . warn ( `Warning: The argument '${ argument } ' has been deprecated and has no effect anymore` )
539
549
break
550
+ case "typename" :
551
+ options . typename = argument . value
552
+ break
553
+ case "flatten" :
554
+ options . flatten = argument . value
555
+ break
556
+ case "examples" :
557
+ options . example = argument . value
558
+ break
559
+ case "all-omitempty" :
560
+ options . allOmitempty = argument . value
561
+ break
540
562
default :
541
563
console . error ( `Unexpected argument ${ val } received` )
542
564
process . exit ( 1 )
@@ -546,7 +568,7 @@ if (typeof module != 'undefined') {
546
568
if ( filename ) {
547
569
const fs = require ( 'fs' ) ;
548
570
const json = fs . readFileSync ( filename , 'utf8' ) ;
549
- jsonToGoWithErrorHandling ( json )
571
+ jsonToGoWithErrorHandling ( json , options )
550
572
return
551
573
}
552
574
@@ -557,7 +579,7 @@ if (typeof module != 'undefined') {
557
579
} )
558
580
process . stdin . on ( 'end' , function ( ) {
559
581
const json = Buffer . concat ( bufs ) . toString ( 'utf8' )
560
- jsonToGoWithErrorHandling ( json )
582
+ jsonToGoWithErrorHandling ( json , options )
561
583
} )
562
584
return
563
585
}
0 commit comments