Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
875 B

using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Windows.Input;
using StabilityMatrix.Core.Extensions;
namespace StabilityMatrix.Avalonia.Models;
public partial record CommandItem
{
public ICommand Command { get; init; }
public string DisplayName { get; init; }
public CommandItem(ICommand command, [CallerArgumentExpression("command")] string? commandName = null)
{
Command = command;
DisplayName = commandName == null ? "" : ProcessName(commandName);
}
[Pure]
private static string ProcessName(string name)
{
name = name.StripEnd("Command");
name = SpaceTitleCaseRegex().Replace(name, "$1 $2");
return name;
}
[GeneratedRegex("([a-z])_?([A-Z])")]
private static partial Regex SpaceTitleCaseRegex();
}