Exemple #1
0
        public bool TryExecute(ILog log, IEnumerable <ICommandActionListener> listeners = null)
        {
            //No data to manipulate. Need to transmit though
            if (listeners != null)
            {
                SystemCommandResult result = new SystemCommandResult(this, true, CommandKind);
                foreach (var listener in listeners)
                {
                    listener.OnCommand(result);
                }
            }

            return(true);
        }
 public void OnCommand(SystemCommandResult result)
 {
     if (result.CommandKind == CommandKind.Exit)
     {
         Console.WriteLine("Goodbye.");
         ExitListener?.Exit();
     }
     else if (result.CommandKind == CommandKind.Version)
     {
         Console.WriteLine($"Version {System.Reflection.Assembly.GetEntryAssembly().GetName().Version}");
     }
     else if (result.CommandKind == CommandKind.ClearConsole)
     {
         Console.Clear();
     }
     else if (result.CommandKind == CommandKind.Help)
     {
         HelpInfoWriter.WriteCommandList(CommandLibrary);
     }
 }
Exemple #3
0
 public virtual void OnCommand(SystemCommandResult result)
 {
     _results.Add(result);
 }