Improve ArgsProcessor a bit.
MODIFY
WalletWasabi.Packager/ArgsProcessor.cs
WalletWasabi.Packager/ArgsProcessor.cs
@@ -16,64 +16,25 @@ namespace WalletWasabi.Packager
public string[] Args { get; }
- public bool IsReduceOnionsMode()
- {
- foreach (var arg in Args)
- {
- string value = arg.Trim().TrimStart('-');
+ public bool IsReduceOnionsMode() => IsOneOf("reduceonions", "reduceonion");
- if (value.Equals("reduceonions", StringComparison.OrdinalIgnoreCase)
- || value.Equals("reduceonion", StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- }
+ public bool IsOnlyCreateDigestsMode() => IsOneOf("onlycreatedigests", "onlycreatedigest", "onlydigests", "onlydigest");
- return false;
- }
+ public bool IsOnlyBinariesMode() => IsOneOf("onlybinaries");
- public bool IsOnlyCreateDigestsMode()
- {
- foreach (var arg in Args)
- {
- string value = arg.Trim().TrimStart('-');
+ public bool IsGetOnionsMode() => IsOneOf("getonions", "getonion");
- if (value.Equals("onlycreatedigests", StringComparison.OrdinalIgnoreCase)
- || value.Equals("onlycreatedigest", StringComparison.OrdinalIgnoreCase)
- || value.Equals("onlydigests", StringComparison.OrdinalIgnoreCase)
- || value.Equals("onlydigest", StringComparison.OrdinalIgnoreCase))
+ private bool IsOneOf(params string[] values)
{
- return true;
- }
- }
-
- return false;
- }
-
- public bool IsOnlyBinariesMode()
+ foreach (var value in values)
{
foreach (var arg in Args)
{
- if (arg.Trim().TrimStart('-').Equals("onlybinaries", StringComparison.OrdinalIgnoreCase))
+ if (arg.Trim().TrimStart('-').Equals(value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
-
- return false;
- }
-
- public bool IsGetOnionsMode()
- {
- foreach (var arg in Args)
- {
- string value = arg.Trim().TrimStart('-');
-
- if (value.Equals("getonions", StringComparison.OrdinalIgnoreCase)
- || value.Equals("getonion", StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
}
return false;

Improve ArgsProcessor a bit.