using Quadarax.Foundation.Common.Console;
using Quadarax.Foundation.Common.Value;
using Quadarax.Foundation.QConsole.Attributes;
using Quadarax.Foundation.QConsole.Command;
using Quadarax.Foundation.QConsole.Command.Base;

namespace Quadarax.Foundation.QConsole.DevBench.Command
{
    [CommandDefinition]
    public class TestCmd : AbstractSelectionCommand
    {
        public override string Name => "TEST";
        public override string Description => "Description of TEST";
        protected override Result OnExecute()
        {
            var items = new Entry[]
            {
                new Entry("Name1", "Value1"),
                new Entry("Name2", "Value2"),
                new Entry("Name3", "Value3"),
                new Entry("Name4", "Value4"),
                new Entry("Name5", "Value5"),
                new Entry("Name6", "Value6"),
                new Entry("Name7", "Value7"),
                new Entry("Name8", "Value8"),
                new Entry("Name9", "Value9"),
                new Entry("Name10", "Value10"),
                new Entry("Name11", "Value11"),
                new Entry("Name12", "Value12"),
                new Entry("Name13", "Value13"),
                new Entry("Name14", "Value14"),
                new Entry("Name15", "Value15"),
                new Entry("Name16", "Value16"),
                new Entry("Name17", "Value17"),
                new Entry("Name18", "Value18"),
                new Entry("Name19", "Value19"),
                new Entry("Name20", "Value20"),
                new Entry("Name21", "Value21"),
                new Entry("Name22", "Value22"),
                new Entry("Name23", "Value23"),
                new Entry("Name24", "Value24"),
                new Entry("Name25", "Value25"),
                new Entry("Name26", "Value26"),
                new Entry("Name27", "Value27"),
                new Entry("Name28", "Value28"),
            };
            SetModel(items);
            return new Result();
        }

        public TestCmd(Engine engine) : base(engine, 1, 5)
        {
            EnableDefaultPagingMode();
            EnableDefaultSelectionMode();
        }

        //protected override bool IsStoredToGlobal => true;

        protected override void OnWriteEntry(ConsoleWriter writer, ISelectionEntry entry)
        {
            var entryTyped = (Entry) entry;
            writer.WriteLine($"Name={entryTyped.Name}\tValue={entryTyped.Value}");
        }

        protected override bool IsStoredToGlobal => true;
    }
}
