-
Notifications
You must be signed in to change notification settings - Fork 12
/
CommandLineArguments.cs
45 lines (39 loc) · 1.11 KB
/
CommandLineArguments.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WfcPatcher {
static class CommandLineArguments {
public static string[] Filenames { get; private set; }
public static string Domain = null;
public static bool ParseCommandLineArguments( string[] args ) {
bool parseSuccess = true;
try {
List<string> filenames = new List<string>();
for ( int i = 0; i < args.Length; ++i ) {
switch ( args[i] ) {
case "-d":
case "--domain":
string domain = args[++i];
int maxLength = "nintendowifi.net".Length;
if ( domain.Length <= maxLength ) {
Domain = domain;
} else {
Console.WriteLine( "Replacement domain cannot be longer than original domain ({0} characters).", maxLength );
parseSuccess = false;
}
break;
default:
filenames.Add( args[i] );
break;
}
}
Filenames = filenames.ToArray();
} catch ( IndexOutOfRangeException ) {
Console.WriteLine( "Last given option needs more parameters!" );
parseSuccess = false;
}
return parseSuccess;
}
}
}