mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-25 15:35:02 +00:00
Replace --include-threads and --include-archived-threads with a single multi-value option
Related to #1119
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using CliFx.Extensibility;
|
||||
using DiscordChatExporter.Cli.Commands.Shared;
|
||||
|
||||
namespace DiscordChatExporter.Cli.Commands.Converters;
|
||||
|
||||
internal class ThreadInclusionBindingConverter : BindingConverter<ThreadInclusion>
|
||||
{
|
||||
public override ThreadInclusion Convert(string? rawValue)
|
||||
{
|
||||
// Empty or unset value is treated as 'active' to match the previous behavior
|
||||
if (string.IsNullOrWhiteSpace(rawValue))
|
||||
return ThreadInclusion.Active;
|
||||
|
||||
// Boolean 'true' is treated as 'active', boolean 'false' is treated as 'none'
|
||||
if (bool.TryParse(rawValue, out var boolValue))
|
||||
return boolValue ? ThreadInclusion.Active : ThreadInclusion.None;
|
||||
|
||||
// Otherwise, fall back to regular enum parsing
|
||||
return Enum.Parse<ThreadInclusion>(rawValue, true);
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,15 @@ internal class TruthyBooleanBindingConverter : BindingConverter<bool>
|
||||
{
|
||||
public override bool Convert(string? rawValue)
|
||||
{
|
||||
// Null is still considered true, to match the base behavior
|
||||
if (rawValue is null)
|
||||
// Empty or unset value is treated as 'true', to match the regular boolean behavior
|
||||
if (string.IsNullOrWhiteSpace(rawValue))
|
||||
return true;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(rawValue))
|
||||
return false;
|
||||
// Number '1' is treated as 'true', other numbers are treated as 'false'
|
||||
if (int.TryParse(rawValue, CultureInfo.InvariantCulture, out var intValue))
|
||||
return intValue == 1;
|
||||
|
||||
if (bool.TryParse(rawValue, out var boolValue))
|
||||
return boolValue;
|
||||
|
||||
if (int.TryParse(rawValue, CultureInfo.InvariantCulture, out var intValue) && intValue == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
// Otherwise, fall back to regular boolean parsing
|
||||
return bool.Parse(rawValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user