You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
1 year ago
|
using System;
|
||
|
using System.Linq;
|
||
|
|
||
|
namespace UnityEditor.TestTools.CodeCoverage.CommandLineParser
|
||
|
{
|
||
|
internal class CommandLineOption : ICommandLineOption
|
||
|
{
|
||
|
readonly Action<string> m_ArgAction;
|
||
|
|
||
|
public CommandLineOption(string argName, Action action)
|
||
|
{
|
||
|
ArgName = argName;
|
||
|
m_ArgAction = s => action();
|
||
|
}
|
||
|
|
||
|
public CommandLineOption(string argName, Action<string> action)
|
||
|
{
|
||
|
ArgName = argName;
|
||
|
m_ArgAction = action;
|
||
|
}
|
||
|
|
||
|
public CommandLineOption(string argName, Action<string[]> action)
|
||
|
{
|
||
|
ArgName = argName;
|
||
|
m_ArgAction = s => action(SplitStringToArray(s));
|
||
|
}
|
||
|
|
||
|
public string ArgName { get; private set; }
|
||
|
|
||
|
public void ApplyValue(string value)
|
||
|
{
|
||
|
m_ArgAction(value);
|
||
|
}
|
||
|
|
||
|
static string[] SplitStringToArray(string value)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(value))
|
||
|
{
|
||
|
return new string[] { };
|
||
|
}
|
||
|
|
||
|
return value.Split(';').ToArray();
|
||
|
}
|
||
|
}
|
||
|
}
|