-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParams.cs
41 lines (36 loc) · 894 Bytes
/
Params.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
namespace App {
class Params {
// data
/// <summary>
/// Indicates whether to append to file.
/// </summary>
public bool Append;
/// <summary>
/// Name of file to write to.
/// </summary>
public string File = "";
// constructor
/// <summary>
/// Get parameters from input arguments.
/// </summary>
/// <param name="args">Input arguments.</param>
public Params(string[] args) {
for (int i = 0; i < args.Length; i++) {
string a = args[i];
if (a.StartsWith("--")) { SetOption(a.Substring(2, 1)); continue; }
if (a.StartsWith("-")) { SetOption(a.Substring(1)); continue; }
File = a;
}
}
// method
/// <summary>
/// Set options from option string.
/// </summary>
/// <param name="o">Option string.</param>
private void SetOption(string o) {
foreach(char c in o.ToLower()) {
if (c == 'a') Append = true;
}
}
}
}