@@ -67,17 +67,9 @@ type Config struct {
67
67
// If set, the string to use for the start of each line.
68
68
StartingIndent []byte
69
69
70
- // Set to true if you like verbosity, I guess.
71
- // If false, strings will only have kind+type markings if they're typed.
72
- //
73
- // Not yet supported.
74
- AlwaysMarkStrings bool
75
-
76
- // Set to true if you want type info to be skipped for any type that's in the Prelude
77
- // (e.g. instead of `string<String>{` seeing only `string{` is preferred, etc).
78
- //
79
- // Not yet supported.
80
- ElidePreludeTypeInfo bool
70
+ // If set to true, scalar values will be omitted from the output. This is useful for representing
71
+ // the structure of a graph without the data.
72
+ OmitScalarValues bool
81
73
82
74
// Set to true if you want maps to use "complex"-style printouts:
83
75
// meaning they will print their keys on separate lines than their values,
@@ -356,31 +348,41 @@ func (z *printBuf) doString(indentLevel int, printState uint8, n datamodel.Node)
356
348
}
357
349
z .writeString ("}" )
358
350
case datamodel .Kind_Int :
359
- x , _ := n .AsInt ()
360
- z .writeString ("{" )
361
- z .writeString (strconv .FormatInt (x , 10 ))
362
- z .writeString ("}" )
351
+ if ! z .Config .OmitScalarValues {
352
+ x , _ := n .AsInt ()
353
+ z .writeString ("{" )
354
+ z .writeString (strconv .FormatInt (x , 10 ))
355
+ z .writeString ("}" )
356
+ }
363
357
case datamodel .Kind_Float :
364
- x , _ := n .AsFloat ()
365
- z .writeString ("{" )
366
- z .writeString (strconv .FormatFloat (x , 'f' , - 1 , 64 ))
367
- z .writeString ("}" )
358
+ if ! z .Config .OmitScalarValues {
359
+ x , _ := n .AsFloat ()
360
+ z .writeString ("{" )
361
+ z .writeString (strconv .FormatFloat (x , 'f' , - 1 , 64 ))
362
+ z .writeString ("}" )
363
+ }
368
364
case datamodel .Kind_String :
369
- x , _ := n .AsString ()
370
- z .writeString ("{" )
371
- z .writeString (strconv .QuoteToGraphic (x ))
372
- z .writeString ("}" )
365
+ if ! z .Config .OmitScalarValues {
366
+ x , _ := n .AsString ()
367
+ z .writeString ("{" )
368
+ z .writeString (strconv .QuoteToGraphic (x ))
369
+ z .writeString ("}" )
370
+ }
373
371
case datamodel .Kind_Bytes :
374
- x , _ := n .AsBytes ()
375
- z .writeString ("{" )
376
- dst := make ([]byte , hex .EncodedLen (len (x )))
377
- hex .Encode (dst , x )
378
- z .writeString (string (dst ))
379
- z .writeString ("}" )
372
+ if ! z .Config .OmitScalarValues {
373
+ x , _ := n .AsBytes ()
374
+ z .writeString ("{" )
375
+ dst := make ([]byte , hex .EncodedLen (len (x )))
376
+ hex .Encode (dst , x )
377
+ z .writeString (string (dst ))
378
+ z .writeString ("}" )
379
+ }
380
380
case datamodel .Kind_Link :
381
- x , _ := n .AsLink ()
382
- z .writeString ("{" )
383
- z .writeString (x .String ())
384
- z .writeString ("}" )
381
+ if ! z .Config .OmitScalarValues {
382
+ x , _ := n .AsLink ()
383
+ z .writeString ("{" )
384
+ z .writeString (x .String ())
385
+ z .writeString ("}" )
386
+ }
385
387
}
386
388
}
0 commit comments