| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Quadarax.Foundation.Core.Console;
- using Quadarax.Foundation.Core.QConsole.Argument;
- using Quadarax.Foundation.Core.QConsole.Attributes;
- using Quadarax.Foundation.Core.QConsole.Command.Base;
- using Quadarax.Foundation.Core.QConsole.Value;
- using Quadarax.Foundation.Core.Value;
- namespace Quadarax.Foundation.Core.QConsole.Command.Defaults
- {
- [CommandDefinition]
- public class CmdSelection : AbstractListCommand
- {
- #region *** Properties ***
- public override string Name => Constants.Commands.Selection.Name;
- public override string Description => Constants.Commands.Selection.Description;
- #endregion
- #region *** Constructors ***
- public CmdSelection(Engine engine) : base(engine)
- {
- }
- #endregion
-
- #region *** Protected overrides ***
- protected override IEnumerable<AbstractArgument> OnSetupArguments()
- {
- var arguments = base.OnSetupArguments().ToList();
- arguments.AddRange(
- new []
- {
- new FlagArgument(Constants.Arguments.Selection.List.Code,
- Constants.Arguments.Selection.List.Description, Constants.Arguments.Selection.List.Hint, true),
- new FlagArgument(Constants.Arguments.Selection.Clear.Code,
- Constants.Arguments.Selection.Clear.Description, Constants.Arguments.Selection.Clear.Hint,
- false),
- new NamedArgument(Constants.Arguments.Selection.Delete.Code,
- Constants.Arguments.Selection.Delete.Description, Constants.Arguments.Selection.Delete.Hint,
- TypeValuesEnum.String, string.Empty, false),
- });
- return arguments;
- }
- protected override void OnWriteEntry(ConsoleWriter writer, ISelectionEntry entry)
- {
- writer.Write("ID: ");
- writer.Write(entry.GetIdentifier());
- writer.Write("\t");
- writer.Write("Value: ");
- writer.WriteLine(entry.GetDisplayValue());
- }
- protected override Result EndExecute(Result incommingResult)
- {
- var result = base.EndExecute(incommingResult);
- using (var writerWhite = new ConsoleWriter(ConsoleColor.White))
- {
- writerWhite.WriteLine(
- $"For selection variable usage use {QConsole.Defaults.RoleCharacters.SelectionVariablePrefixCharacter}<selection_ordinal>.<property_name> in console.");
- }
- return result;
- }
- protected override Result OnExecute()
- {
- SetModel(Engine.Selections);
- return new Result();
- }
- #endregion
- }
- }
|