66using System . Reflection ;
77using System . Runtime . InteropServices ;
88using System . Globalization ;
9+ using Semmle . Util ;
910using Semmle . Util . Logging ;
1011
1112namespace Semmle . Extraction . CIL . Driver
@@ -169,18 +170,13 @@ public void ResolveReferences()
169170 /// <summary>
170171 /// Parses the command line and collates a list of DLLs/EXEs to extract.
171172 /// </summary>
172- internal class ExtractorOptions
173+ internal class ExtractorOptions : CommonOptions
173174 {
174175 private readonly AssemblyList assemblyList = new AssemblyList ( ) ;
175176
176177 public ExtractorOptions ( string [ ] args )
177178 {
178- Verbosity = Verbosity . Info ;
179- Threads = System . Environment . ProcessorCount ;
180- PDB = true ;
181- TrapCompression = TrapWriter . CompressionMode . Gzip ;
182-
183- ParseArgs ( args ) ;
179+ this . ParseArguments ( args . Append ( "--pdb" ) . ToArray ( ) ) ;
184180
185181 AddFrameworkDirectories ( false ) ;
186182
@@ -203,12 +199,6 @@ private void AddFrameworkDirectories(bool extractAll)
203199 AddDirectory ( RuntimeEnvironment . GetRuntimeDirectory ( ) , extractAll ) ;
204200 }
205201
206- public Verbosity Verbosity { get ; private set ; }
207- public bool NoCache { get ; private set ; }
208- public int Threads { get ; private set ; }
209- public bool PDB { get ; private set ; }
210- public TrapWriter . CompressionMode TrapCompression { get ; private set ; }
211-
212202 private void AddFileOrDirectory ( string path )
213203 {
214204 path = Path . GetFullPath ( path ) ;
@@ -237,43 +227,25 @@ private void AddFileOrDirectory(string path)
237227 /// </summary>
238228 public IEnumerable < AssemblyName > MissingReferences => assemblyList . MissingReferences ;
239229
240- private void ParseArgs ( string [ ] args )
230+ public override bool HandleFlag ( string flag , bool value )
241231 {
242- foreach ( var arg in args )
232+ switch ( flag )
243233 {
244- if ( arg == "--verbose" )
245- {
246- Verbosity = Verbosity . All ;
247- }
248- else if ( arg == "--silent" )
249- {
250- Verbosity = Verbosity . Off ;
251- }
252- else if ( arg . StartsWith ( "--verbosity:" ) )
253- {
254- Verbosity = ( Verbosity ) int . Parse ( arg . Substring ( 12 ) ) ;
255- }
256- else if ( arg == "--dotnet" )
257- {
258- AddFrameworkDirectories ( true ) ;
259- }
260- else if ( arg == "--nocache" )
261- {
262- NoCache = true ;
263- }
264- else if ( arg . StartsWith ( "--threads:" ) )
265- {
266- Threads = int . Parse ( arg . Substring ( 10 ) ) ;
267- }
268- else if ( arg == "--no-pdb" )
269- {
270- PDB = false ;
271- }
272- else
273- {
274- AddFileOrDirectory ( arg ) ;
275- }
234+ case "dotnet" :
235+ if ( value )
236+ AddFrameworkDirectories ( true ) ;
237+ return true ;
238+ default :
239+ return base . HandleFlag ( flag , value ) ;
276240 }
277241 }
242+
243+ public override bool HandleArgument ( string argument )
244+ {
245+ AddFileOrDirectory ( argument ) ;
246+ return true ;
247+ }
248+
249+ public override void InvalidArgument ( string argument ) { }
278250 }
279251}
0 commit comments