mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-18 22:24:53 +02:00
Configuration
Core
Bridge
Controls
Handling
Notification
Other
Utils
BrowserCache.cs
BrowserUtils.cs
CommandLineArgs.cs
CommandLineArgsParser.cs
HardwareAcceleration.cs
InjectedHTML.cs
NativeCoreAudio.cs
NativeMethods.cs
TwoKeyDictionary.cs
WindowState.cs
WindowsUtils.cs
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
TrayIcon.Designer.cs
TrayIcon.cs
Libraries
Plugins
Properties
Resources
Updates
bld
subprocess
tests
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
_postbuild.bat
packages.config
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace TweetDuck.Core.Utils{
|
|
static class CommandLineArgsParser{
|
|
private static Regex splitRegex;
|
|
|
|
private static Regex SplitRegex => splitRegex ?? (splitRegex = new Regex(@"([^=\s]+(?:=(?:[^ ]*""[^""]*?""[^ ]*|[^ ]*))?)", RegexOptions.Compiled));
|
|
|
|
public static CommandLineArgs ReadCefArguments(string argumentString){
|
|
CommandLineArgs args = new CommandLineArgs();
|
|
|
|
if (string.IsNullOrWhiteSpace(argumentString)){
|
|
return args;
|
|
}
|
|
|
|
foreach(Match match in SplitRegex.Matches(argumentString)){
|
|
string matchValue = match.Value;
|
|
|
|
int indexEquals = matchValue.IndexOf('=');
|
|
string key, value;
|
|
|
|
if (indexEquals == -1){
|
|
key = matchValue.TrimStart('-');
|
|
value = "1";
|
|
}
|
|
else{
|
|
key = matchValue.Substring(0, indexEquals).TrimStart('-');
|
|
value = matchValue.Substring(indexEquals+1).Trim('"');
|
|
}
|
|
|
|
if (key.Length != 0){
|
|
args.SetValue(key, value);
|
|
}
|
|
}
|
|
|
|
return args;
|
|
}
|
|
}
|
|
}
|