Skip to content

Commit

Permalink
🚑 fix add skill command
Browse files Browse the repository at this point in the history
resolve invalid cast going from base class (addcommandsettings) to derived class (addskillsettings) so I made the generic AddCommand class the base (swapping it with the non-generic class)
  • Loading branch information
csc530 committed Aug 2, 2024
1 parent 0f54de7 commit 8d5ed89
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions Resumer/cli/commands/add/AddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Resumer.cli.commands.add;

public abstract class AddCommand: Command<AddCommandSettings>
public abstract class AddCommand: AddCommand<AddCommandSettings>;

public abstract class AddCommand<T>: Command<T> where T : notnull, AddCommandSettings
{
/** prompt displayed to continue adding items */
protected virtual string ContinuePrompt { get; } = "Add another item?";

public sealed override int Execute(CommandContext context, AddCommandSettings settings)
protected virtual string ContinuePrompt { get; } = "Add another item?";
protected abstract int AddItem(CommandContext context, T settings);
public sealed override int Execute(CommandContext context, T settings)
{
int result;
do
Expand All @@ -19,14 +22,6 @@ public sealed override int Execute(CommandContext context, AddCommandSettings se

return result;
}

protected abstract int AddItem(CommandContext context, AddCommandSettings settings);
}

public abstract class AddCommand<T>: AddCommand where T : AddCommandSettings
{
protected abstract int AddItem(CommandContext context, T settings);
protected sealed override int AddItem(CommandContext context, AddCommandSettings settings) => AddItem(context, (T)settings);
};

public class AddCommandSettings: CommandSettings
Expand Down

0 comments on commit 8d5ed89

Please sign in to comment.