forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (44 loc) · 1.51 KB
/
Program.cs
File metadata and controls
51 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.IO;
using System.Linq;
namespace ScriptCs
{
internal static class Program
{
[LoaderOptimizationAttribute(LoaderOptimization.MultiDomain)]
private static int Main(string[] args)
{
ProfileOptimizationShim.SetProfileRoot(Path.GetDirectoryName(typeof(Program).Assembly.Location));
ProfileOptimizationShim.StartProfile(typeof(Program).Assembly.GetName().Name + ".profile");
var nonScriptArgs = args.TakeWhile(arg => arg != "--").ToArray();
var scriptArgs = args.Skip(nonScriptArgs.Length + 1).ToArray();
ScriptCsArgs commandArgs;
try
{
commandArgs = ScriptCsArgs.Parse(nonScriptArgs);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ScriptCsArgs.GetUsage());
return 1;
}
if (commandArgs.Help)
{
Console.WriteLine(ScriptCsArgs.GetUsage());
return 0;
}
if (commandArgs.Version)
{
VersionWriter.Write();
return 0;
}
if (commandArgs.Config != null && !File.Exists(commandArgs.Config))
{
Console.WriteLine("The specified config file does not exist.");
return 1;
}
return Application.Run(Config.Create(commandArgs), scriptArgs);
}
}
}