-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArguments.cs
35 lines (28 loc) · 885 Bytes
/
Arguments.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace johnshope.Sync {
public class Arguments: List<string> {
public Arguments(string[] args) : base(args.ToList()) { }
public bool Has(string option) {
int i = IndexOf(option);
if (i >= 0) {
RemoveAt(i);
return true;
}
return false;
}
public bool Has(string option, out string parameter) {
int i = IndexOf(option);
if (i >= 0 && i < Count-1) {
parameter = this[i+1];
RemoveRange(i, 2);
return true;
}
parameter = null;
return false;
}
public string Pop() { if (Count > 0) { var p = this[0]; RemoveAt(0); return p; } return null; }
}
}