1
1
use clap:: { Parser , Subcommand } ;
2
- use colored_json:: ToColoredJson ;
2
+ use colored_json:: { Color , ColorMode , Output , Styler , ToColoredJson } ;
3
3
use iab_gpp:: sections:: SectionId ;
4
4
use iab_gpp:: v1:: GPPString ;
5
5
use num_traits:: cast:: FromPrimitive ;
@@ -61,7 +61,8 @@ fn parse_gpp_string(s: &str) -> Result<(), Box<dyn std::error::Error>> {
61
61
62
62
println ! (
63
63
"{}" ,
64
- serde_json:: to_string_pretty( & sections) ?. to_colored_json_auto( ) ?
64
+ serde_json:: to_string_pretty( & sections) ?
65
+ . to_colored_json_with_styler( ColorMode :: Auto ( Output :: StdOut ) , json_color_styler( ) ) ?
65
66
) ;
66
67
67
68
Ok ( ( ) )
@@ -74,7 +75,8 @@ fn parse_gpp_string_section(s: &str, id: u32) -> Result<(), Box<dyn std::error::
74
75
75
76
println ! (
76
77
"{}" ,
77
- serde_json:: to_string_pretty( & section) ?. to_colored_json_auto( ) ?
78
+ serde_json:: to_string_pretty( & section) ?
79
+ . to_colored_json_with_styler( ColorMode :: Auto ( Output :: StdOut ) , json_color_styler( ) ) ?
78
80
) ;
79
81
80
82
Ok ( ( ) )
@@ -89,3 +91,15 @@ fn list_sections(s: &str) -> Result<(), Box<dyn std::error::Error>> {
89
91
90
92
Ok ( ( ) )
91
93
}
94
+
95
+ fn json_color_styler ( ) -> Styler {
96
+ Styler {
97
+ key : Color :: Green . foreground ( ) ,
98
+ string_value : Color :: Blue . bold ( ) ,
99
+ integer_value : Color :: Magenta . bold ( ) ,
100
+ float_value : Color :: Magenta . italic ( ) ,
101
+ object_brackets : Color :: Yellow . bold ( ) ,
102
+ array_brackets : Color :: Cyan . bold ( ) ,
103
+ ..Default :: default ( )
104
+ }
105
+ }
0 commit comments