21 lines
750 B
C#
21 lines
750 B
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace OnScreenKeyboard
|
|
{
|
|
public static class ArgsParse
|
|
{
|
|
public static string Get(this string[] args, string argName)
|
|
{
|
|
string selected = null;
|
|
foreach (string s in args)
|
|
if (s.TrimStart('-', '/').ToLower().StartsWith($"{argName.ToLower()}:"))
|
|
selected = string.Join("", s.TrimStart('-', '/').Skip(argName.Length + 1));
|
|
return selected;
|
|
}
|
|
|
|
public static T Get<T>(this string[] args, string argName, Func<string, T> func) => func(args.Get(argName));
|
|
|
|
public static bool GetBool(this string[] args, string argName) => args.Any(s => s.ToLower().TrimStart('-', '/') == argName.ToLower());
|
|
}
|
|
} |