22using System . IO ;
33using System . Linq ;
44using System . Text ;
5+ using System . Collections . Generic ;
56using System . Runtime . InteropServices ;
67using Microsoft . Win32 ;
78using VDFparse ;
@@ -102,20 +103,35 @@ static int Main(string[] args)
102103 case "info" :
103104 return Info ( vdfFile ) ;
104105 }
105- uint id ;
106- bool success = uint . TryParse ( args [ 2 ] , out id ) ;
107- if ( ! success )
106+ List < Dataset > processing ;
107+ if ( args [ 2 ] == "*" )
108108 {
109- Console . Error . WriteLine ( ErrorInvalidNumber , args [ 2 ] ) ;
110- return 5 ;
109+ processing = vdfFile . Datasets ;
110+ }
111+ else
112+ {
113+ uint id ;
114+ bool success = uint . TryParse ( args [ 2 ] , out id ) ;
115+ if ( ! success )
116+ {
117+ Console . Error . WriteLine ( ErrorInvalidNumber , args [ 2 ] ) ;
118+ return 5 ;
119+ }
120+ var dataset = vdfFile . FindByID ( id ) ;
121+ if ( dataset == null )
122+ {
123+ Console . Error . WriteLine ( ErrorNoId , id ) ;
124+ return 6 ;
125+ }
126+ processing = new List < Dataset > { dataset } ;
111127 }
112128 switch ( args [ 0 ] )
113129 {
114130 case "json" :
115131 int . TryParse ( args . ElementAtOrDefault ( 4 ) , out int indent ) ;
116- return Json ( vdfFile , id , indent : 4 ) ;
132+ return Json ( processing , indent : 4 ) ;
117133 case "query" :
118- return Query ( vdfFile , id , args . Skip ( 3 ) . ToArray ( ) ) ;
134+ return Query ( processing , args . Skip ( 3 ) . ToArray ( ) ) ;
119135 }
120136 }
121137 catch ( Exception e )
@@ -137,29 +153,23 @@ static int Info(VDFFile source)
137153 return 0 ;
138154 }
139155
140- static int Json ( VDFFile source , uint id , int indent )
156+ static int Json ( List < Dataset > datasets , int indent )
141157 {
142- var dataset = source . FindByID ( id ) ;
143- if ( dataset == null )
158+ foreach ( var dataset in datasets )
144159 {
145- Console . Error . WriteLine ( ErrorNoId , id ) ;
146- return 6 ;
160+ Console . WriteLine ( dataset . Data . ToJSON ( indent : indent ) ) ;
147161 }
148- Console . WriteLine ( dataset . Data . ToJSON ( indent : indent ) ) ;
149162 return 0 ;
150163 }
151164
152- static int Query ( VDFFile source , uint id , string [ ] queries )
165+ static int Query ( List < Dataset > datasets , string [ ] queries )
153166 {
154- var dataset = source . FindByID ( id ) ;
155- if ( dataset == null )
156- {
157- Console . Error . WriteLine ( ErrorNoId , id ) ;
158- return 6 ;
159- }
160- foreach ( var query in queries )
167+ foreach ( var dataset in datasets )
161168 {
162- Console . WriteLine ( String . Join ( "\n " , dataset . Data . Search ( query ) ) ) ;
169+ foreach ( var query in queries )
170+ {
171+ Console . WriteLine ( String . Join ( "\n " , dataset . Data . Search ( query ) ) ) ;
172+ }
163173 }
164174 return 0 ;
165175 }
0 commit comments