Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
92 lines (82 loc) · 3.1 KB
/
Copy pathProgram.cs
File metadata and controls
92 lines (82 loc) · 3.1 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Copyright 2017 YANG Huan ([email protected]).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSharpLua {
class Program {
private const string HelpCmdString = @"Usage: CSharp.lua [-s srcfolder] [-d dstfolder]
Arguments
-s : source directory, all *.cs files whill be compiled
-d : destination directory, will put the out lua files
Options
-h : show the help message
-l : libraries referenced, use ';' to separate
-m : meta files, like System.xml, use ';' to separate
-csc : csc.exe command argumnets, use ';' to separate
-c : support classic lua version(5.1), default support 5.3
-i : indent number, default is 2
-a : attributes need to export, use ';' to separate, if ""-a"" only, all attributes whill be exported
";
public static void Main(string[] args) {
if (args.Length > 0) {
try {
var cmds = Utility.GetCommondLines(args);
if (cmds.ContainsKey("-h")) {
ShowHelpInfo();
return;
}
Console.WriteLine($"start {DateTime.Now}");
string folder = cmds.GetArgument("-s");
string output = cmds.GetArgument("-d");
string lib = cmds.GetArgument("-l", true);
string meta = cmds.GetArgument("-m", true);
string csc = cmds.GetArgument("-csc", true);
bool isClassic = cmds.ContainsKey("-c");
string indent = cmds.GetArgument("-i", true);
string atts = cmds.GetArgument("-a", true);
if (atts == null && cmds.ContainsKey("-a")) {
atts = string.Empty;
}
Worker w = new Worker(folder, output, lib, meta, csc, isClassic, indent, atts);
w.Do();
Console.WriteLine("all operator success");
Console.WriteLine($"end {DateTime.Now}");
}
catch (CmdArgumentException e) {
Console.Error.WriteLine(e.Message);
ShowHelpInfo();
Environment.ExitCode = -1;
}
catch (CompilationErrorException e) {
Console.Error.WriteLine(e.Message);
Environment.ExitCode = -1;
}
catch (Exception e) {
Console.Error.WriteLine(e.ToString());
Environment.ExitCode = -1;
}
}
else {
ShowHelpInfo();
Environment.ExitCode = -1;
}
}
private static void ShowHelpInfo() {
Console.Error.WriteLine(HelpCmdString);
}
}
}