Innovenergy_trunk/csharp/app/FossilTui/FossilState.cs

43 lines
1.6 KiB
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using static InnovEnergy.FossilTui.FossilAction;
namespace InnovEnergy.FossilTui;
public record FossilState
{
public String Name { get; }
public ConsoleColor Color { get; }
public IReadOnlyList<FossilAction> AvailableActions { get; }
public static FossilState Parse(String state) => States.Single(s => s.Name == state);
public static readonly FossilState Missing = new("MISSING" , ConsoleColor.Red, new[] { Ignore, Revert });
public static readonly FossilState Deleted = new("DELETED" , ConsoleColor.DarkRed, new[] { Ignore, Commit, Revert });
public static readonly FossilState Added = new("ADDED" , ConsoleColor.DarkGreen, new[] { Ignore, Commit, Delete });
public static readonly FossilState Edited = new("EDITED" , ConsoleColor.Yellow, new[] { Ignore, Commit, Delete }); // Revert will bring it back to not edited
public static readonly FossilState Extra = new("EXTRA" , ConsoleColor.Green, new[] { Ignore, Add, Delete});
//public static readonly FossilState Unchanged = new("UNCHANGED", ConsoleColor.DarkGray, new[] { Ignore, Commit, Revert });
private static readonly IReadOnlyList<FossilState> States = new[]
{
Missing,
Deleted,
Added,
Edited,
Extra,
// Unchanged,
};
private FossilState(String name, ConsoleColor color, IReadOnlyList<FossilAction> availableActions)
{
Name = name;
Color = color;
AvailableActions = availableActions;
}
public override String ToString() => Name;
}