1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 using System.Collections.Generic; 10 using Antmicro.Renode.UserInterface.Tokenizer; 11 using AntShell.Commands; 12 using Antmicro.Renode.Logging; 13 using Antmicro.Renode.Core; 14 15 namespace Antmicro.Renode.UserInterface.Commands 16 { 17 public class QuitCommand : Command 18 { 19 [Runnable] Run(ICommandInteraction writer)20 public void Run(ICommandInteraction writer) 21 { 22 writer.WriteLine("Renode is quitting", ConsoleColor.Green); 23 SetCurrentMachine(null); 24 Quitted?.Invoke()?.Invoke(); 25 writer.QuitEnvironment = true; 26 } 27 28 private Action<Machine> SetCurrentMachine; 29 private event Func<Action> Quitted; 30 QuitCommand(Monitor monitor, Action<Machine> setCurrentMachine, Func<Action> quitted)31 public QuitCommand(Monitor monitor, Action<Machine> setCurrentMachine, Func<Action> quitted) : base(monitor, "quit", "quits the emulator.", "q") 32 { 33 SetCurrentMachine = setCurrentMachine; 34 Quitted = quitted; 35 } 36 } 37 } 38 39