Skip to content

Commit b0c62c8

Browse files
committed
C#: Refactor functionality to run standalone extractor into own method.
1 parent d947861 commit b0c62c8

File tree

1 file changed

+21
-17
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp.Standalone

1 file changed

+21
-17
lines changed

csharp/extractor/Semmle.Extraction.CSharp.Standalone/Program.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,8 @@ public void Dispose()
5151

5252
public class Program
5353
{
54-
public static int Main(string[] args)
54+
public static Extractor.ExitCode Run(Options options)
5555
{
56-
Extractor.SetInvariantCulture();
57-
58-
var options = Options.Create(args);
59-
// options.CIL = true; // To do: Enable this
60-
61-
if (options.Help)
62-
{
63-
Options.ShowHelp(System.Console.Out);
64-
return 0;
65-
}
66-
67-
if (options.Errors)
68-
return 1;
69-
7056
var stopwatch = new Stopwatch();
7157
stopwatch.Start();
7258

@@ -78,7 +64,7 @@ public static int Main(string[] args)
7864
if (sourceFileCount == 0)
7965
{
8066
logger.Log(Severity.Error, "No source files found");
81-
return 1;
67+
return Extractor.ExitCode.Errors;
8268
}
8369

8470
if (!options.SkipExtraction)
@@ -95,8 +81,26 @@ public static int Main(string[] args)
9581
options);
9682
logger.Log(Severity.Info, $"Extraction completed in {stopwatch.Elapsed}");
9783
}
84+
return Extractor.ExitCode.Ok;
85+
}
86+
87+
public static int Main(string[] args)
88+
{
89+
Extractor.SetInvariantCulture();
90+
91+
var options = Options.Create(args);
92+
// options.CIL = true; // To do: Enable this
93+
94+
if (options.Help)
95+
{
96+
Options.ShowHelp(System.Console.Out);
97+
return 0;
98+
}
99+
100+
if (options.Errors)
101+
return 1;
98102

99-
return 0;
103+
return (int)Run(options);
100104
}
101105

102106
private class ExtractionProgress : IProgressMonitor

0 commit comments

Comments
 (0)