-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
56 lines (48 loc) · 1.92 KB
/
Program.cs
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
using System;
namespace Jannesen.Tools.SourceCleaner
{
public sealed class Program
{
static void Main(string[] args)
{
try {
var globbing = (Globbing)null;
var cleaner = new SourceCleaner();
foreach(var arg in args) {
if (arg.StartsWith("--", StringComparison.Ordinal)) {
var i = arg.IndexOf('=', 2);
var name = (i > 0) ? arg.Substring(2, i-2) : arg.Substring(2);
var value = (i > 0) ? arg.Substring(i+1) : null;
switch(name) {
case "path":
if (String.IsNullOrWhiteSpace(value))
throw new FormatException("Invalid path value");
if (globbing != null) {
cleaner.Run(globbing);
}
globbing = new Globbing(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), value));
break;
default:
cleaner.SetOption(name, value);
break;
}
}
else {
if (globbing == null) {
globbing = new Globbing(System.IO.Directory.GetCurrentDirectory());
}
globbing.Pattern(arg);
}
}
cleaner.Run(globbing);
}
catch(Exception err) {
while (err != null) {
System.Diagnostics.Debug.WriteLine("ERROR: " + err.Message);
Console.WriteLine("ERROR: " + err.Message);
err = err.InnerException;
}
}
}
}
}