1 //
2 // Copyright (c) 2010-2023 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 AntShell.Commands;
11 using System.Text;
12 using System.Linq;
13 using Antmicro.Renode.Utilities;
14 
15 namespace Antmicro.Renode.UserInterface.Commands
16 {
17 
18     public abstract class AutoLoadCommand : Command, IAutoLoadType
19     {
AutoLoadCommand(Monitor monitor, string name, string description, params string[] alternativeNames)20         protected AutoLoadCommand(Monitor monitor, string name, string description, params string[] alternativeNames) : base(monitor, name, description, alternativeNames)
21         {
22         }
23     }
24 
25     public abstract class Command : ICommandDescription
26     {
27         protected readonly Monitor monitor;
28 
Command(Monitor monitor, string name, string description, params string[] alternativeNames)29 		protected Command(Monitor monitor, string name, string description, params string[] alternativeNames)
30 		{
31 			this.monitor = monitor;
32 			Description = description;
33 			Name = name;
34 			AlternativeNames = alternativeNames;
35 		}
36 
37         public string[] AlternativeNames {get; private set;}
38         public string Name { get; private set; }
39         public string Description{ get; private set; }
40 
PrintHelp(ICommandInteraction writer)41         public virtual void PrintHelp(ICommandInteraction writer)
42         {
43             writer.WriteLine(this.GetHelp());
44         }
45     }
46 
47     public class CommandComparer : IEqualityComparer<Command>
48     {
Equals(Command x, Command y)49         public bool Equals(Command x, Command y)
50         {
51             return x.Name == y.Name;
52         }
53 
GetHashCode(Command obj)54         public int GetHashCode(Command obj)
55         {
56             return obj.Name.GetHashCode();
57         }
58     }
59 }
60 
61