Skip to content

Commit a24c335

Browse files
committed
Add program parameter changing settings
1 parent 07f2204 commit a24c335

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/Program.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Reflection;
4+
using System.Text.RegularExpressions;
45

56
namespace RadiantMapToWavefrontObj
67
{
@@ -24,6 +25,8 @@ static void Main(string[] args)
2425
ConvertFile(arg);
2526
success = true;
2627
}
28+
else
29+
HandleArgument(arg);
2730
}
2831

2932
if (!success)
@@ -51,5 +54,32 @@ private static void ConvertFile(string path)
5154
DateTime endTime = DateTime.Now;
5255
Console.WriteLine("Finished in: " + (endTime-startTime).Milliseconds + "ms.");
5356
}
57+
58+
// Handle a settings argument.
59+
private static void HandleArgument(string arg)
60+
{
61+
string pattern = @"-(\w+)=(\w+)";
62+
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
63+
Match m = regex.Match(arg);
64+
if (m.Success)
65+
{
66+
string type = m.Groups[1].ToString();
67+
string mode = m.Groups[2].ToString();
68+
69+
if (type == "autoclose")
70+
{
71+
if (mode == "false" || mode == "0")
72+
_autoclose = false;
73+
else if (mode == "true" || mode == "1")
74+
_autoclose = true;
75+
}
76+
else if (type == "scale")
77+
{
78+
double scale;
79+
if (Double.TryParse(mode, out scale))
80+
_scale = scale;
81+
}
82+
}
83+
}
5484
}
5585
}

0 commit comments

Comments
 (0)