@@ -513,9 +513,10 @@ function jsonToGov2(json, options = {}) {
513513if ( typeof module != 'undefined' ) {
514514 if ( ! module . parent ) {
515515 let filename = null
516+ let options = { }
516517
517- function jsonToGoWithErrorHandling ( json ) {
518- const output = jsonToGov2 ( json )
518+ function jsonToGoWithErrorHandling ( json , options ) {
519+ const output = jsonToGov2 ( json , options )
519520 if ( output . error ) {
520521 console . error ( output . error )
521522 process . exitCode = 1
@@ -532,11 +533,32 @@ if (typeof module != 'undefined') {
532533 return
533534 }
534535
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 ) {
537547 case "big" :
538548 console . warn ( `Warning: The argument '${ argument } ' has been deprecated and has no effect anymore` )
539549 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
540562 default :
541563 console . error ( `Unexpected argument ${ val } received` )
542564 process . exit ( 1 )
@@ -546,7 +568,7 @@ if (typeof module != 'undefined') {
546568 if ( filename ) {
547569 const fs = require ( 'fs' ) ;
548570 const json = fs . readFileSync ( filename , 'utf8' ) ;
549- jsonToGoWithErrorHandling ( json )
571+ jsonToGoWithErrorHandling ( json , options )
550572 return
551573 }
552574
@@ -557,7 +579,7 @@ if (typeof module != 'undefined') {
557579 } )
558580 process . stdin . on ( 'end' , function ( ) {
559581 const json = Buffer . concat ( bufs ) . toString ( 'utf8' )
560- jsonToGoWithErrorHandling ( json )
582+ jsonToGoWithErrorHandling ( json , options )
561583 } )
562584 return
563585 }
0 commit comments