using System.IO; using Semmle.Util; using Semmle.Util.Logging; using Semmle.Extraction.CSharp.DependencyFetching; using System; namespace Semmle.Extraction.CSharp.Standalone { /// /// The options controlling standalone extraction. /// public sealed class Options : CommonOptions { public override bool HandleFlag(string key, bool value) { switch (key) { case "help": Help = true; return true; default: return base.HandleFlag(key, value); } } public override bool HandleArgument(string arg) { return true; } public override void InvalidArgument(string argument) { System.Console.WriteLine($"[{Environment.CurrentManagedThreadId:D3}] Error: Invalid argument {argument}"); Errors = true; } /// /// The directory containing the source code; /// public string SrcDir { get; } = Directory.GetCurrentDirectory(); /// /// Whether errors were encountered parsing the arguments. /// public bool Errors { get; private set; } = false; /// /// Whether to show help. /// public bool Help { get; private set; } = false; /// /// Outputs the command line options to the console. /// public static void ShowHelp(TextWriter output) { output.WriteLine("C# standalone extractor\n\nExtracts a C# project in the current directory without performing a build.\n"); output.WriteLine("Additional options:\n"); output.WriteLine(" --threads:nnn Specify number of threads (default=CPU cores)"); output.WriteLine(" --verbose Produce more output"); } private Options() { } public static Options Create(string[] args) { var options = new Options(); options.ParseArguments(args); return options; } } }