Skip to content

Commit ad63106

Browse files
added error codes
1 parent e7e39fa commit ad63106

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

rctc/Program.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace ReCT
1717
{
1818
internal static class Program
1919
{
20-
private static void Main(string[] args)
20+
private static int Main(string[] args)
2121
{
2222
string outputPath = default;
2323
string moduleName = default;
@@ -60,28 +60,28 @@ private static void Main(string[] args)
6060

6161
if (args.Length != 0 && args[0] == "create") {
6262
projectActions(args);
63-
return;
63+
return 0;
6464
}
6565

6666
if (args.Length != 0 && args[0] == "run") {
6767
projectRun();
68-
return;
68+
return 0;
6969
}
7070

7171
options.Parse(args);
7272

7373
if (helpRequested)
7474
{
7575
options.WriteOptionDescriptions(Console.Out);
76-
return;
76+
return 0;
7777
}
7878

7979
if (sourcePaths.Count == 0)
8080
{
8181
Console.ForegroundColor = ConsoleColor.Red;
8282
Console.Error.WriteLine("Error: need at least one source file");
8383
Console.ForegroundColor = ConsoleColor.White;
84-
return;
84+
return -1;
8585
}
8686
else
8787
Console.WriteLine("Source: " + sourcePaths[0]);
@@ -142,7 +142,7 @@ private static void Main(string[] args)
142142
Console.Error.WriteDiagnostics(parserDiagnostics, attachments.ToArray());
143143
Console.ForegroundColor = ConsoleColor.White;
144144
}
145-
return;
145+
return -1;
146146
}
147147

148148
syntaxTrees[pathIndex] = syntaxTree;
@@ -165,7 +165,7 @@ private static void Main(string[] args)
165165
{
166166
compilation.PrepareProgram();
167167
ReturnCompilationData(compilation);
168-
return;
168+
return 0;
169169
}
170170

171171
ImmutableArray<Diagnostic> diagnostics = compilation.Emit(moduleName, referencePaths.ToArray(), outputPath);
@@ -180,7 +180,7 @@ private static void Main(string[] args)
180180
Console.Error.WriteDiagnostics(diagnostics, attachments.ToArray());
181181
Console.ForegroundColor = ConsoleColor.White;
182182
}
183-
return;
183+
return -1;
184184
}
185185

186186
//create runtime config
@@ -235,6 +235,8 @@ private static void Main(string[] args)
235235
Console.ForegroundColor = ConsoleColor.Green;
236236
Console.WriteLine("\n=> Compilation Complete!");
237237
Console.ForegroundColor = ConsoleColor.White;
238+
239+
return 0;
238240
}
239241

240242
static void projectRun()

0 commit comments

Comments
 (0)