Rasagar/Library/PackageCache/com.unity.test-framework/UnityEditor.TestRunner/CommandLineParser/CommandLineOption.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2024-08-26 13:07:20 -07:00
using System;
namespace UnityEditor.TestRunner.CommandLineParser
{
internal class CommandLineOption : ICommandLineOption
{
private 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);
}
private static string[] SplitStringToArray(string value)
{
if (string.IsNullOrEmpty(value))
{
return null;
}
return value.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);
}
}
}