diff --git a/CHANGELIST.md b/CHANGELIST.md
index da404177..e1ee9528 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -31,6 +31,7 @@
- Add self-formatting to Input types
- Handle issue with old .NET
- Let inputs read equal-separated values
+- Fix some formatting issues with Input types
### 3.2.4 (2024-11-24)
diff --git a/MPF.ExecutionContexts/Data/BooleanInput.cs b/MPF.ExecutionContexts/Data/BooleanInput.cs
index cf9b99eb..b4864d1a 100644
--- a/MPF.ExecutionContexts/Data/BooleanInput.cs
+++ b/MPF.ExecutionContexts/Data/BooleanInput.cs
@@ -38,10 +38,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Separator
if (useEquals)
@@ -63,7 +60,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -85,7 +82,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/FlagInput.cs b/MPF.ExecutionContexts/Data/FlagInput.cs
index 5c6fa5ce..dae2df7e 100644
--- a/MPF.ExecutionContexts/Data/FlagInput.cs
+++ b/MPF.ExecutionContexts/Data/FlagInput.cs
@@ -38,10 +38,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
return builder.ToString();
}
@@ -54,7 +51,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check the name
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
Value = true;
return true;
diff --git a/MPF.ExecutionContexts/Data/Input.cs b/MPF.ExecutionContexts/Data/Input.cs
index 24e1e99a..5706bad6 100644
--- a/MPF.ExecutionContexts/Data/Input.cs
+++ b/MPF.ExecutionContexts/Data/Input.cs
@@ -15,20 +15,20 @@ namespace MPF.ExecutionContexts.Data
public readonly string Name;
///
- /// Indicates if a value has been set
+ /// Short name for the input
///
- public abstract bool ValueSet { get; }
-
- ///
- /// Verbose name for the input
- ///
- protected readonly string? _longName;
+ protected readonly string? _shortName;
///
/// Indicates if the value following is required or not
///
protected readonly bool _required;
+ ///
+ /// Indicates if a value has been set
+ ///
+ public abstract bool ValueSet { get; }
+
#endregion
#region Constructors
@@ -37,7 +37,7 @@ namespace MPF.ExecutionContexts.Data
public Input(string name)
{
Name = name;
- _longName = null;
+ _shortName = null;
_required = true;
}
@@ -46,7 +46,7 @@ namespace MPF.ExecutionContexts.Data
public Input(string name, bool required)
{
Name = name;
- _longName = null;
+ _shortName = null;
_required = required;
}
@@ -54,8 +54,8 @@ namespace MPF.ExecutionContexts.Data
/// Verbose flag name / value
public Input(string shortName, string longName)
{
- Name = shortName;
- _longName = longName;
+ Name = longName;
+ _shortName = shortName;
_required = true;
}
@@ -64,8 +64,8 @@ namespace MPF.ExecutionContexts.Data
/// Indicates if a following value is required
public Input(string shortName, string longName, bool required)
{
- Name = shortName;
- _longName = longName;
+ Name = longName;
+ _shortName = shortName;
_required = required;
}
@@ -73,6 +73,11 @@ namespace MPF.ExecutionContexts.Data
#region Functionality
+ ///
+ /// Clear any accumulated value
+ ///
+ public abstract void ClearValue();
+
///
/// Create a formatted representation of the input and possible value
///
@@ -209,5 +214,23 @@ namespace MPF.ExecutionContexts.Data
: base(shortName, longName, required) { }
#endregion
+
+ #region Functionality
+
+ ///
+ public override void ClearValue()
+ {
+ Value = default;
+ }
+
+ ///
+ /// Set a new value
+ ///
+ public void SetValue(T value)
+ {
+ Value = value;
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/MPF.ExecutionContexts/Data/Int16Input.cs b/MPF.ExecutionContexts/Data/Int16Input.cs
index cf01fcad..f37e02b7 100644
--- a/MPF.ExecutionContexts/Data/Int16Input.cs
+++ b/MPF.ExecutionContexts/Data/Int16Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != short.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/Int32Input.cs b/MPF.ExecutionContexts/Data/Int32Input.cs
index 93c14c92..4f5fbc6c 100644
--- a/MPF.ExecutionContexts/Data/Int32Input.cs
+++ b/MPF.ExecutionContexts/Data/Int32Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != int.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/Int64Input.cs b/MPF.ExecutionContexts/Data/Int64Input.cs
index 65ec4260..f532eabf 100644
--- a/MPF.ExecutionContexts/Data/Int64Input.cs
+++ b/MPF.ExecutionContexts/Data/Int64Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != long.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/Int8Input.cs b/MPF.ExecutionContexts/Data/Int8Input.cs
index f37e81d5..da2e9895 100644
--- a/MPF.ExecutionContexts/Data/Int8Input.cs
+++ b/MPF.ExecutionContexts/Data/Int8Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != sbyte.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/StringInput.cs b/MPF.ExecutionContexts/Data/StringInput.cs
index f68fcf7b..755c967d 100644
--- a/MPF.ExecutionContexts/Data/StringInput.cs
+++ b/MPF.ExecutionContexts/Data/StringInput.cs
@@ -42,10 +42,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != string.Empty))
@@ -57,7 +54,7 @@ namespace MPF.ExecutionContexts.Data
builder.Append(" ");
// Value
- builder.Append(Value.ToString());
+ builder.Append($"\"{Value}\"");
}
return builder.ToString();
@@ -71,7 +68,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -86,7 +83,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/UInt16Input.cs b/MPF.ExecutionContexts/Data/UInt16Input.cs
index 873da452..b28569f6 100644
--- a/MPF.ExecutionContexts/Data/UInt16Input.cs
+++ b/MPF.ExecutionContexts/Data/UInt16Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != ushort.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/UInt32Input.cs b/MPF.ExecutionContexts/Data/UInt32Input.cs
index 521c700a..2728d755 100644
--- a/MPF.ExecutionContexts/Data/UInt32Input.cs
+++ b/MPF.ExecutionContexts/Data/UInt32Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != uint.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/UInt64Input.cs b/MPF.ExecutionContexts/Data/UInt64Input.cs
index a7ad8922..36f176da 100644
--- a/MPF.ExecutionContexts/Data/UInt64Input.cs
+++ b/MPF.ExecutionContexts/Data/UInt64Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != ulong.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');
diff --git a/MPF.ExecutionContexts/Data/UInt8Input.cs b/MPF.ExecutionContexts/Data/UInt8Input.cs
index af64b7ca..c56a280c 100644
--- a/MPF.ExecutionContexts/Data/UInt8Input.cs
+++ b/MPF.ExecutionContexts/Data/UInt8Input.cs
@@ -43,10 +43,7 @@ namespace MPF.ExecutionContexts.Data
var builder = new StringBuilder();
// Flag name
- if (_longName != null)
- builder.Append(_longName);
- else
- builder.Append(Name);
+ builder.Append(Name);
// Only output separator and value if needed
if (_required || (!_required && Value != byte.MinValue))
@@ -72,7 +69,7 @@ namespace MPF.ExecutionContexts.Data
return false;
// Check for space-separated
- if (parts[index] == Name || (_longName != null && parts[index] == _longName))
+ if (parts[index] == Name || (_shortName != null && parts[index] == _shortName))
{
// Ensure the value exists
if (index + 1 >= parts.Length)
@@ -95,7 +92,7 @@ namespace MPF.ExecutionContexts.Data
}
// Check for equal separated
- if (parts[index].StartsWith($"{Name}=") || (_longName != null && parts[index].StartsWith($"{_longName}=")))
+ if (parts[index].StartsWith($"{Name}=") || (_shortName != null && parts[index].StartsWith($"{_shortName}=")))
{
// Split the string, using the first equal sign as the separator
string[] tempSplit = parts[index].Split('=');