@@ -512,9 +512,10 @@ function jsonToGov2(json, options = {}) {
512512if ( typeof module != 'undefined' ) {
513513 if ( ! module . parent ) {
514514 let filename = null
515+ let options = { }
515516
516- function jsonToGoWithErrorHandling ( json ) {
517- const output = jsonToGov2 ( json )
517+ function jsonToGoWithErrorHandling ( json , options ) {
518+ const output = jsonToGov2 ( json , options )
518519 if ( output . error ) {
519520 console . error ( output . error )
520521 process . exitCode = 1
@@ -531,11 +532,32 @@ if (typeof module != 'undefined') {
531532 return
532533 }
533534
534- const argument = val . replace ( / - / g, '' )
535- switch ( argument ) {
535+ let argument = {
536+ arg : val . split ( "=" ) [ 0 ] . replace ( / ^ - + / , '' ) ,
537+ value : val . split ( "=" ) [ 1 ] || true ,
538+ }
539+
540+ if ( argument . arg . startsWith ( "no-" ) ) {
541+ argument . arg = argument . arg . replace ( / ^ n o - / , '' )
542+ argument . value = ! argument . value
543+ }
544+
545+ switch ( argument . arg ) {
536546 case "big" :
537547 console . warn ( `Warning: The argument '${ argument } ' has been deprecated and has no effect anymore` )
538548 break
549+ case "typename" :
550+ options . typename = argument . value
551+ break
552+ case "flatten" :
553+ options . flatten = argument . value
554+ break
555+ case "examples" :
556+ options . example = argument . value
557+ break
558+ case "all-omitempty" :
559+ options . allOmitempty = argument . value
560+ break
539561 default :
540562 console . error ( `Unexpected argument ${ val } received` )
541563 process . exit ( 1 )
@@ -545,7 +567,7 @@ if (typeof module != 'undefined') {
545567 if ( filename ) {
546568 const fs = require ( 'fs' ) ;
547569 const json = fs . readFileSync ( filename , 'utf8' ) ;
548- jsonToGoWithErrorHandling ( json )
570+ jsonToGoWithErrorHandling ( json , options )
549571 return
550572 }
551573
@@ -556,7 +578,7 @@ if (typeof module != 'undefined') {
556578 } )
557579 process . stdin . on ( 'end' , function ( ) {
558580 const json = Buffer . concat ( bufs ) . toString ( 'utf8' )
559- jsonToGoWithErrorHandling ( json )
581+ jsonToGoWithErrorHandling ( json , options )
560582 } )
561583 return
562584 }
0 commit comments