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,14 @@ 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 ;
180179 PDB = true ;
181- TrapCompression = TrapWriter . CompressionMode . Gzip ;
182-
183- ParseArgs ( args ) ;
180+ this . ParseArguments ( args ) ;
184181
185182 AddFrameworkDirectories ( false ) ;
186183
@@ -203,12 +200,6 @@ private void AddFrameworkDirectories(bool extractAll)
203200 AddDirectory ( RuntimeEnvironment . GetRuntimeDirectory ( ) , extractAll ) ;
204201 }
205202
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-
212203 private void AddFileOrDirectory ( string path )
213204 {
214205 path = Path . GetFullPath ( path ) ;
@@ -237,43 +228,25 @@ private void AddFileOrDirectory(string path)
237228 /// </summary>
238229 public IEnumerable < AssemblyName > MissingReferences => assemblyList . MissingReferences ;
239230
240- private void ParseArgs ( string [ ] args )
231+ public override bool HandleFlag ( string flag , bool value )
241232 {
242- foreach ( var arg in args )
233+ switch ( flag )
243234 {
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- }
235+ case "dotnet" :
236+ if ( value )
237+ AddFrameworkDirectories ( true ) ;
238+ return true ;
239+ default :
240+ return base . HandleFlag ( flag , value ) ;
276241 }
277242 }
243+
244+ public override bool HandleArgument ( string argument )
245+ {
246+ AddFileOrDirectory ( argument ) ;
247+ return true ;
248+ }
249+
250+ public override void InvalidArgument ( string argument ) { }
278251 }
279252}
0 commit comments