2
2
using System . IO ;
3
3
using System . Linq ;
4
4
using System . Text ;
5
+ using System . Collections . Generic ;
5
6
using System . Runtime . InteropServices ;
6
7
using Microsoft . Win32 ;
7
8
using VDFparse ;
@@ -102,20 +103,35 @@ static int Main(string[] args)
102
103
case "info" :
103
104
return Info ( vdfFile ) ;
104
105
}
105
- uint id ;
106
- bool success = uint . TryParse ( args [ 2 ] , out id ) ;
107
- if ( ! success )
106
+ List < Dataset > processing ;
107
+ if ( args [ 2 ] == "*" )
108
108
{
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 } ;
111
127
}
112
128
switch ( args [ 0 ] )
113
129
{
114
130
case "json" :
115
131
int . TryParse ( args . ElementAtOrDefault ( 4 ) , out int indent ) ;
116
- return Json ( vdfFile , id , indent : 4 ) ;
132
+ return Json ( processing , indent : 4 ) ;
117
133
case "query" :
118
- return Query ( vdfFile , id , args . Skip ( 3 ) . ToArray ( ) ) ;
134
+ return Query ( processing , args . Skip ( 3 ) . ToArray ( ) ) ;
119
135
}
120
136
}
121
137
catch ( Exception e )
@@ -137,29 +153,23 @@ static int Info(VDFFile source)
137
153
return 0 ;
138
154
}
139
155
140
- static int Json ( VDFFile source , uint id , int indent )
156
+ static int Json ( List < Dataset > datasets , int indent )
141
157
{
142
- var dataset = source . FindByID ( id ) ;
143
- if ( dataset == null )
158
+ foreach ( var dataset in datasets )
144
159
{
145
- Console . Error . WriteLine ( ErrorNoId , id ) ;
146
- return 6 ;
160
+ Console . WriteLine ( dataset . Data . ToJSON ( indent : indent ) ) ;
147
161
}
148
- Console . WriteLine ( dataset . Data . ToJSON ( indent : indent ) ) ;
149
162
return 0 ;
150
163
}
151
164
152
- static int Query ( VDFFile source , uint id , string [ ] queries )
165
+ static int Query ( List < Dataset > datasets , string [ ] queries )
153
166
{
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 )
161
168
{
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
+ }
163
173
}
164
174
return 0 ;
165
175
}
0 commit comments