1 // 2 // Copyright (c) 2010-2024 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 13 namespace Antmicro.Renode.UserInterface.Commands 14 { 15 public class MonitorPathCommand : Command 16 { PrintHelp(ICommandInteraction writer)17 public override void PrintHelp(ICommandInteraction writer) 18 { 19 base.PrintHelp(writer); 20 writer.WriteLine(); 21 PrintCurrentPath(writer); 22 writer.WriteLine(string.Format("Default 'PATH' value is: {0}", monitorPath.DefaultPath)); 23 writer.WriteLine(); 24 writer.WriteLine("You can use following commands:"); 25 writer.WriteLine(String.Format("'{0} set @path'\tto set 'PATH' to the given value", Name)); 26 writer.WriteLine(String.Format("'{0} add @path'\tto append the given value to 'PATH'", Name)); 27 writer.WriteLine(String.Format("'{0} reset'\t\tto reset 'PATH' to it's default value", Name)); 28 } PrintCurrentPath(ICommandInteraction writer)29 private void PrintCurrentPath(ICommandInteraction writer) 30 { 31 writer.WriteLine(string.Format("Current 'PATH' value is: {0}", monitorPath.Path)); 32 } 33 34 [Runnable] SetOrAdd(ICommandInteraction writer, [Values( R, R)] LiteralToken action, StringToken path)35 public void SetOrAdd(ICommandInteraction writer, [Values( "set", "add")] LiteralToken action, StringToken path) 36 { 37 switch(action.Value) 38 { 39 case "set": 40 monitorPath.Path = path.Value; 41 break; 42 case "add": 43 monitorPath.Append(path.Value); 44 break; 45 } 46 PrintCurrentPath(writer); 47 } 48 49 [Runnable] Reset(ICommandInteraction writer, [Values( R)] LiteralToken action)50 public void Reset(ICommandInteraction writer, [Values( "reset")] LiteralToken action) 51 { 52 monitorPath.Reset(); 53 PrintCurrentPath(writer); 54 } 55 56 MonitorPath monitorPath; MonitorPathCommand(Monitor monitor, MonitorPath path)57 public MonitorPathCommand(Monitor monitor, MonitorPath path) : base(monitor, "path", "allows modification of internal 'PATH' variable.") 58 { 59 monitorPath = path; 60 } 61 } 62 } 63 64