Fix awkward code organization

This commit is contained in:
Matt Nadareski
2025-10-05 15:48:03 -04:00
parent b5c3b0a88c
commit 515eaddfc9
11 changed files with 178 additions and 178 deletions

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!bool.TryParse(args[index + 1], out bool value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!bool.TryParse(args[index + 1], out bool value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!short.TryParse(args[index + 1], out short value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!short.TryParse(args[index + 1], out short value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!int.TryParse(args[index + 1], out int value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!int.TryParse(args[index + 1], out int value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!long.TryParse(args[index + 1], out long value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!long.TryParse(args[index + 1], out long value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!sbyte.TryParse(args[index + 1], out sbyte value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!sbyte.TryParse(args[index + 1], out sbyte value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,8 +47,19 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for equal separated
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
string val = string.Join("=", tempSplit, 1, tempSplit.Length - 1);
Value = val;
return true;
}
// Check for space-separated
if (!part.Contains("="))
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
@@ -58,17 +69,6 @@ namespace SabreTools.CommandLine.Inputs
Value = args[index];
return true;
}
// Check for equal separated
else
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
string val = string.Join("=", tempSplit, 1, tempSplit.Length - 1);
Value = val;
return true;
}
}
/// <inheritdoc/>

View File

@@ -48,8 +48,20 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for equal separated
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
string val = string.Join("=", tempSplit, 1, tempSplit.Length - 1);
Value ??= [];
Value.Add(val);
return true;
}
// Check for space-separated
if (!part.Contains("="))
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
@@ -60,18 +72,6 @@ namespace SabreTools.CommandLine.Inputs
Value.Add(args[index]);
return true;
}
// Check for equal separated
else
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
string val = string.Join("=", tempSplit, 1, tempSplit.Length - 1);
Value ??= [];
Value.Add(val);
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!ushort.TryParse(args[index + 1], out ushort value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!ushort.TryParse(args[index + 1], out ushort value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!uint.TryParse(args[index + 1], out uint value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!uint.TryParse(args[index + 1], out uint value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!ulong.TryParse(args[index + 1], out ulong value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!ulong.TryParse(args[index + 1], out ulong value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>

View File

@@ -47,24 +47,8 @@ namespace SabreTools.CommandLine.Inputs
return false;
}
// Check for space-separated
if (!part.Contains("="))
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!byte.TryParse(args[index + 1], out byte value))
return false;
index++;
Value = value;
return true;
}
// Check for equal separated
else
if (part.Contains("="))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = part.Split('=');
@@ -81,6 +65,22 @@ namespace SabreTools.CommandLine.Inputs
Value = value;
return true;
}
// Check for space-separated
else
{
// Ensure the value exists
if (index + 1 >= args.Length)
return false;
// If the next value is valid
if (!byte.TryParse(args[index + 1], out byte value))
return false;
index++;
Value = value;
return true;
}
}
/// <inheritdoc/>