blob: df683e503a5f378108beda1c4df9b0c5d26bd62e (
plain)
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.Linq;
using System.Collections.Generic;
namespace PkiAuthenticator
{
internal class ProcessArguments
{
private readonly List<string> _args;
public ProcessArguments(string[] args) => _args = args.ToList();
public bool HasArg(string arg) => _args.Contains(arg, StringComparer.OrdinalIgnoreCase);
public bool Verbose => HasArg("-v") || HasArg("--verbose");
public bool Debug => HasArg("-d") || HasArg("--debug");
public bool Silent => HasArg("-s") || HasArg("--silent");
public bool RpMalloc => HasArg("--rpmalloc");
public bool DoubleVerbose => Verbose && HasArg("-vv");
public bool LogHttp => HasArg("--log-http");
/// <summary>
/// Gets the value following the specified argument, or
/// null no value follows the specified argument
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
public string? GetArg(string arg)
{
int index = _args.IndexOf(arg);
return index == -1 || index + 1 >= _args.Count ? null : _args[index + 1];
}
}
}
|