-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParams.cs
More file actions
46 lines (41 loc) · 1.06 KB
/
Params.cs
File metadata and controls
46 lines (41 loc) · 1.06 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
namespace App {
class Params {
// data
/// <summary>
/// Indicates whether escape sequences are to be expanded.
/// </summary>
public bool Expand;
/// <summary>
/// Indicates if there is supposed to be no newline at end.
/// </summary>
public bool NoNewline;
/// <summary>
/// Stores the actual value to be written.
/// </summary>
public string Value = "";
// constructor
/// <summary>
/// Get parameters for 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; }
Value += a;
}
}
// method
/// <summary>
/// Set options from option string.
/// </summary>
/// <param name="o">Option string.</param>
public void SetOption(string o) {
foreach(char c in o.ToLower()) {
if (c == 'e') Expand = true;
else if (c == 'n') NoNewline = true;
}
}
}
}