-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLine.cs
More file actions
39 lines (37 loc) · 1.24 KB
/
CommandLine.cs
File metadata and controls
39 lines (37 loc) · 1.24 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
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace NeoFlyExport
{
/// <summary>
/// Command line utilities
/// </summary>
public static class CommandLine
{
private static Dictionary<string, string> _args;
/// <summary>
/// Simple command line arugments parser
/// Supports --key=value and /key=value syntaxes
/// </summary>
public static Dictionary<string, string> Arguments
{
get
{
if (_args == null)
{
_args = new Dictionary<string, string>();
Regex reKeyValue = new Regex(@"^(--|/)(\w*)=(.*)$", RegexOptions.IgnoreCase);
foreach (string arg in Environment.GetCommandLineArgs())
{
Match keyValueMatch = reKeyValue.Match(arg);
if (keyValueMatch.Success && keyValueMatch.Groups.Count == 4)
{
_args.Add(keyValueMatch.Groups[2].Value.ToLower(), keyValueMatch.Groups[3].Value);
}
}
}
return _args;
}
}
}
}