From 515eaddfc9dc56cf1245d528631f10be6cf9ce40 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 5 Oct 2025 15:48:03 -0400 Subject: [PATCH] Fix awkward code organization --- SabreTools.CommandLine/Inputs/BooleanInput.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/Int16Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/Int32Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/Int64Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/Int8Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/StringInput.cs | 24 ++++++------- .../Inputs/StringListInput.cs | 26 +++++++------- SabreTools.CommandLine/Inputs/UInt16Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/UInt32Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/UInt64Input.cs | 34 +++++++++---------- SabreTools.CommandLine/Inputs/UInt8Input.cs | 34 +++++++++---------- 11 files changed, 178 insertions(+), 178 deletions(-) diff --git a/SabreTools.CommandLine/Inputs/BooleanInput.cs b/SabreTools.CommandLine/Inputs/BooleanInput.cs index 494045e..2c13d6e 100644 --- a/SabreTools.CommandLine/Inputs/BooleanInput.cs +++ b/SabreTools.CommandLine/Inputs/BooleanInput.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/Int16Input.cs b/SabreTools.CommandLine/Inputs/Int16Input.cs index b57c626..ea0e778 100644 --- a/SabreTools.CommandLine/Inputs/Int16Input.cs +++ b/SabreTools.CommandLine/Inputs/Int16Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/Int32Input.cs b/SabreTools.CommandLine/Inputs/Int32Input.cs index 09e935f..916d554 100644 --- a/SabreTools.CommandLine/Inputs/Int32Input.cs +++ b/SabreTools.CommandLine/Inputs/Int32Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/Int64Input.cs b/SabreTools.CommandLine/Inputs/Int64Input.cs index f87e584..7a05223 100644 --- a/SabreTools.CommandLine/Inputs/Int64Input.cs +++ b/SabreTools.CommandLine/Inputs/Int64Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/Int8Input.cs b/SabreTools.CommandLine/Inputs/Int8Input.cs index 48acd82..cf4b2c6 100644 --- a/SabreTools.CommandLine/Inputs/Int8Input.cs +++ b/SabreTools.CommandLine/Inputs/Int8Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/StringInput.cs b/SabreTools.CommandLine/Inputs/StringInput.cs index dcaae0d..459d9ea 100644 --- a/SabreTools.CommandLine/Inputs/StringInput.cs +++ b/SabreTools.CommandLine/Inputs/StringInput.cs @@ -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; - } } /// diff --git a/SabreTools.CommandLine/Inputs/StringListInput.cs b/SabreTools.CommandLine/Inputs/StringListInput.cs index d066586..4cece3b 100644 --- a/SabreTools.CommandLine/Inputs/StringListInput.cs +++ b/SabreTools.CommandLine/Inputs/StringListInput.cs @@ -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; - } } /// diff --git a/SabreTools.CommandLine/Inputs/UInt16Input.cs b/SabreTools.CommandLine/Inputs/UInt16Input.cs index 482305f..44b8ec5 100644 --- a/SabreTools.CommandLine/Inputs/UInt16Input.cs +++ b/SabreTools.CommandLine/Inputs/UInt16Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/UInt32Input.cs b/SabreTools.CommandLine/Inputs/UInt32Input.cs index 54188df..ffa20d1 100644 --- a/SabreTools.CommandLine/Inputs/UInt32Input.cs +++ b/SabreTools.CommandLine/Inputs/UInt32Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/UInt64Input.cs b/SabreTools.CommandLine/Inputs/UInt64Input.cs index 25c62ad..44e64e1 100644 --- a/SabreTools.CommandLine/Inputs/UInt64Input.cs +++ b/SabreTools.CommandLine/Inputs/UInt64Input.cs @@ -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; + } } /// diff --git a/SabreTools.CommandLine/Inputs/UInt8Input.cs b/SabreTools.CommandLine/Inputs/UInt8Input.cs index 9b6ce80..0d45f38 100644 --- a/SabreTools.CommandLine/Inputs/UInt8Input.cs +++ b/SabreTools.CommandLine/Inputs/UInt8Input.cs @@ -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; + } } ///