From 83a6078d33e80a4e1a6593e2e72ab7ce24e93c5e Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Mon, 24 May 2021 21:35:45 +0200 Subject: [PATCH 1/7] implement help system --- BusyList/Commands/Commands.cs | 6 +++- BusyList/Handlers/AddHandler.cs | 11 ++++++- BusyList/Handlers/DeleteHandler.cs | 11 +++++-- BusyList/Handlers/DoneHandler.cs | 7 +++++ BusyList/Handlers/HelpHandler.cs | 45 ++++++++++++++++++++++++++++ BusyList/Handlers/IHandler.cs | 10 +++++-- BusyList/Handlers/NextHandler.cs | 9 +++++- BusyList/Handlers/ReadHandler.cs | 9 +++++- BusyList/HelpSystem/HelpAttribute.cs | 19 ++++++++++++ BusyList/HelpSystem/HelpProvider.cs | 29 ++++++++++++++++++ BusyList/Parsing/CommandGrammar.cs | 20 +++++++++++++ BusyList/Program.cs | 7 +++++ 12 files changed, 175 insertions(+), 8 deletions(-) create mode 100644 BusyList/Handlers/HelpHandler.cs create mode 100644 BusyList/HelpSystem/HelpAttribute.cs create mode 100644 BusyList/HelpSystem/HelpProvider.cs diff --git a/BusyList/Commands/Commands.cs b/BusyList/Commands/Commands.cs index f62c16e..d0a091f 100644 --- a/BusyList/Commands/Commands.cs +++ b/BusyList/Commands/Commands.cs @@ -1,4 +1,6 @@ -namespace BusyList.Commands +using System; + +namespace BusyList.Commands { public record Command; @@ -7,4 +9,6 @@ public record NextCommand() : Command; public record AddCommand(string Description) : Command; public record DeleteCommand(int Id) : Command; public record DoneCommand(int Id) : Command; + public record HelpCommand(string name = null) : Command; } + diff --git a/BusyList/Handlers/AddHandler.cs b/BusyList/Handlers/AddHandler.cs index 4cdcdcb..f3793a1 100644 --- a/BusyList/Handlers/AddHandler.cs +++ b/BusyList/Handlers/AddHandler.cs @@ -1,9 +1,11 @@ using BusyList.Commands; +using BusyList.HelpSystem; using System; namespace BusyList.Handlers { + [HelpAttribute("add", "placeholder", "syntac placeholder")] public class AddHandler : IHandler { private readonly ITaskRepository _taskRepository; @@ -12,6 +14,14 @@ public AddHandler(ITaskRepository taskRepository) { _taskRepository = taskRepository; } + + public void Help() + { + Console.WriteLine("Help: Add\n"); + Console.WriteLine("Function: Create a new task with the given description"); + Console.WriteLine("Syntax: add [id]"); + } + public void Run(AddCommand command) { var item = new AddTaskData(command.Description); @@ -20,6 +30,5 @@ public void Run(AddCommand command) Console.WriteLine($"Added {currentTask.Print()}"); } - } } diff --git a/BusyList/Handlers/DeleteHandler.cs b/BusyList/Handlers/DeleteHandler.cs index 6485a55..e853116 100644 --- a/BusyList/Handlers/DeleteHandler.cs +++ b/BusyList/Handlers/DeleteHandler.cs @@ -11,7 +11,14 @@ public DeleteHandler(ITaskRepository taskRepository) { _taskRepository = taskRepository; } - + + public void Help() + { + Console.WriteLine("Help: Delete\n"); + Console.WriteLine("Function: delete a task"); + Console.WriteLine("Syntax: [id] delete"); + } + public void Run(DeleteCommand command) { var selectedTask = _taskRepository.GetTaskById(command.Id); @@ -19,4 +26,4 @@ public void Run(DeleteCommand command) Console.WriteLine($"Task with id {command.Id} has been deleted."); } } -} \ No newline at end of file +} diff --git a/BusyList/Handlers/DoneHandler.cs b/BusyList/Handlers/DoneHandler.cs index 3828f32..a40532e 100644 --- a/BusyList/Handlers/DoneHandler.cs +++ b/BusyList/Handlers/DoneHandler.cs @@ -12,6 +12,13 @@ public DoneHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } + public void Help() + { + Console.WriteLine("Help: Done\n"); + Console.WriteLine("Function: Mark a task as done"); + Console.WriteLine("Syntax: [id] done"); + } + public void Run(DoneCommand command) { TaskItem taskItem = _taskRepository.GetTaskById(command.Id); diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs new file mode 100644 index 0000000..a2fe09e --- /dev/null +++ b/BusyList/Handlers/HelpHandler.cs @@ -0,0 +1,45 @@ +using BusyList.Commands; +using BusyList.HelpSystem; +using System; + +namespace BusyList.Handlers +{ + public class HelpHandler : IHandler + { + private readonly HelpProvider _helpProvider; + + public HelpHandler(HelpProvider helpProvider) + { + _helpProvider = helpProvider; + } + + public void Help() + { + Console.WriteLine("Commands:\n"); + Console.WriteLine("done - mark a task as done"); + Console.WriteLine("delete - delete a task"); + Console.WriteLine("next - list all tasks"); + Console.WriteLine("read - print the id, description and status of a task\n"); + Console.WriteLine("For more details do: help [keyword] e.g help done"); + } + + public void Run(HelpCommand command) + { + if (command.name == null) + { + Help(); + + return; + } + + var (description, syntax) = _helpProvider.GetHelpText(command.name); + + if (description != null && syntax != null) + { + Console.WriteLine(command.name); + Console.WriteLine(description); + Console.WriteLine(syntax); + } + } + } +} diff --git a/BusyList/Handlers/IHandler.cs b/BusyList/Handlers/IHandler.cs index 9412982..9f17a4c 100644 --- a/BusyList/Handlers/IHandler.cs +++ b/BusyList/Handlers/IHandler.cs @@ -2,8 +2,14 @@ namespace BusyList.Handlers { - internal interface IHandler where TCommand : Command + public interface IHandler where TCommand : Command { void Run(TCommand command); + void Help(); } -} \ No newline at end of file + + internal interface IHelpHandler + { + void Run(IHandler handler) where TCommand : Command; + } +} diff --git a/BusyList/Handlers/NextHandler.cs b/BusyList/Handlers/NextHandler.cs index f07f881..31ae1e2 100644 --- a/BusyList/Handlers/NextHandler.cs +++ b/BusyList/Handlers/NextHandler.cs @@ -29,5 +29,12 @@ public void Run(NextCommand command) Console.WriteLine(SEPERATOR); } } + + public void Help() + { + Console.WriteLine("Help: Next\n"); + Console.WriteLine("Function: Lists all tasks with the id, description and status"); + Console.WriteLine("Syntax: [id]"); + } } -} \ No newline at end of file +} diff --git a/BusyList/Handlers/ReadHandler.cs b/BusyList/Handlers/ReadHandler.cs index 9527c59..b6700c9 100644 --- a/BusyList/Handlers/ReadHandler.cs +++ b/BusyList/Handlers/ReadHandler.cs @@ -12,6 +12,13 @@ public ReadHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } + public void Help() + { + Console.WriteLine("Help: Read\n"); + Console.WriteLine("Function: Give a task by id with the id, the description and the status"); + Console.WriteLine("Syntax: [id]"); + } + public void Run(ReadCommand command) { var task = _taskRepository.GetTaskById(command.Id); @@ -25,4 +32,4 @@ public void Run(ReadCommand command) Console.WriteLine(task.Print()); } } -} \ No newline at end of file +} diff --git a/BusyList/HelpSystem/HelpAttribute.cs b/BusyList/HelpSystem/HelpAttribute.cs new file mode 100644 index 0000000..8d5a53a --- /dev/null +++ b/BusyList/HelpSystem/HelpAttribute.cs @@ -0,0 +1,19 @@ +using System; + +namespace BusyList.HelpSystem +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + public class HelpAttribute : Attribute + { + public string Name { get; } + public string Description { get; } + public string Syntax { get; } + + public HelpAttribute(string name, string description, string syntax) + { + Name = name; + Description = description; + Syntax = syntax; + } + } +} diff --git a/BusyList/HelpSystem/HelpProvider.cs b/BusyList/HelpSystem/HelpProvider.cs new file mode 100644 index 0000000..e60b55b --- /dev/null +++ b/BusyList/HelpSystem/HelpProvider.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace BusyList.HelpSystem +{ + public class HelpProvider + { + private readonly Dictionary _helpText = new(); + + public HelpProvider() + { + _helpText = Assembly.GetExecutingAssembly().GetExportedTypes() + .Where(x => x.IsDefined(typeof(HelpAttribute))) + .Select(x => x.GetCustomAttribute()) + .ToDictionary(x => x.Name.ToLowerInvariant(), x => (x.Description, x.Syntax)); + } + + public (string, string) GetHelpText(string key) + { + if(_helpText.TryGetValue(key, out var value)) + { + return value; + } + + return (null, null); + } + } +} diff --git a/BusyList/Parsing/CommandGrammar.cs b/BusyList/Parsing/CommandGrammar.cs index dc8ed99..b6f99c2 100644 --- a/BusyList/Parsing/CommandGrammar.cs +++ b/BusyList/Parsing/CommandGrammar.cs @@ -1,5 +1,6 @@ using BusyList.Commands; using Sprache; +using System; using System.Linq; namespace BusyList.Parsing @@ -9,6 +10,9 @@ public static class CommandGrammar private static readonly Parser _keywordAdd = Parse.IgnoreCase("add").Text(); + private static readonly Parser _keywordHelp = + Parse.IgnoreCase("help").Text(); + private static readonly Parser _keywordDelete = Parse.IgnoreCase("delete") .Or(Parse.IgnoreCase("del")) @@ -49,12 +53,28 @@ from _ in Parse.WhiteSpace from keyword in _keywordDone select new DoneCommand(id); + private static readonly Parser _overviewHelpCommand = + from keyword in _keywordHelp + select new HelpCommand(null); + + private static readonly Parser _helpCommand = + from keyword in _keywordHelp + select new HelpCommand(); + + private static readonly Parser _helpCommandSpecific = + from keyword in _keywordHelp + from _ in Parse.WhiteSpace + from name in Parse.AnyChar.AtLeastOnce().Text() + select new HelpCommand(name); + public static readonly Parser Source = _deleteCommand .Or(_nextCommand) .Or(_doneCommand) .Or(_readCommand) .Or(_addCommand) + .Or(_helpCommandSpecific) + .Or(_helpCommand) .End(); } } diff --git a/BusyList/Program.cs b/BusyList/Program.cs index 966bdcb..1ec9598 100644 --- a/BusyList/Program.cs +++ b/BusyList/Program.cs @@ -1,9 +1,11 @@ using BusyList.Commands; using BusyList.Handlers; +using BusyList.HelpSystem; using BusyList.Parsing; using Microsoft.Extensions.DependencyInjection; using Sprache; using System; +using System.Reflection; namespace BusyList { @@ -65,6 +67,8 @@ private static IServiceCollection ConfigureServices() services.AddTransient, DoneHandler>(); services.AddTransient, NextHandler>(); services.AddTransient, ReadHandler>(); + services.AddTransient, HelpHandler>(); + services.AddSingleton(); return services; } @@ -88,6 +92,9 @@ private static void HandleCommand(ServiceProvider provider, Command command) case ReadCommand read: provider.GetRequiredService>().Run(read); break; + case HelpCommand help: + provider.GetRequiredService>().Run(help); + break; default: throw new Exception($"Unknown command type {command.GetType().FullName} sent to HandleCommand!"); } From 2ef7eb7393c7f1b4bddb95aa59ac42396b40f325 Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Tue, 25 May 2021 17:44:42 +0200 Subject: [PATCH 2/7] add help texts for command --- BusyList/Handlers/AddHandler.cs | 2 +- BusyList/Handlers/DeleteHandler.cs | 9 ++------- BusyList/Handlers/DoneHandler.cs | 9 ++------- BusyList/Handlers/HelpHandler.cs | 10 +++++++--- BusyList/Handlers/IHandler.cs | 6 ------ BusyList/Handlers/NextHandler.cs | 10 +++------- BusyList/Handlers/ReadHandler.cs | 9 ++------- 7 files changed, 17 insertions(+), 38 deletions(-) diff --git a/BusyList/Handlers/AddHandler.cs b/BusyList/Handlers/AddHandler.cs index f3793a1..9dc8de5 100644 --- a/BusyList/Handlers/AddHandler.cs +++ b/BusyList/Handlers/AddHandler.cs @@ -5,7 +5,7 @@ namespace BusyList.Handlers { - [HelpAttribute("add", "placeholder", "syntac placeholder")] + [HelpAttribute("add", "Add a new task with the passed description", "add [Description]")] public class AddHandler : IHandler { private readonly ITaskRepository _taskRepository; diff --git a/BusyList/Handlers/DeleteHandler.cs b/BusyList/Handlers/DeleteHandler.cs index e853116..4b69c7b 100644 --- a/BusyList/Handlers/DeleteHandler.cs +++ b/BusyList/Handlers/DeleteHandler.cs @@ -1,8 +1,10 @@ using BusyList.Commands; +using BusyList.HelpSystem; using System; namespace BusyList.Handlers { + [HelpAttribute("delete", "Delete the task with the passed id", "[Id] delete")] public class DeleteHandler : IHandler { private readonly ITaskRepository _taskRepository; @@ -12,13 +14,6 @@ public DeleteHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } - public void Help() - { - Console.WriteLine("Help: Delete\n"); - Console.WriteLine("Function: delete a task"); - Console.WriteLine("Syntax: [id] delete"); - } - public void Run(DeleteCommand command) { var selectedTask = _taskRepository.GetTaskById(command.Id); diff --git a/BusyList/Handlers/DoneHandler.cs b/BusyList/Handlers/DoneHandler.cs index a40532e..73e2849 100644 --- a/BusyList/Handlers/DoneHandler.cs +++ b/BusyList/Handlers/DoneHandler.cs @@ -1,8 +1,10 @@ using BusyList.Commands; +using BusyList.HelpSystem; using System; namespace BusyList.Handlers { + [HelpAttribute("done", "Mark the task with the given id as done", "[Id] done")] public class DoneHandler : IHandler { private readonly ITaskRepository _taskRepository; @@ -12,13 +14,6 @@ public DoneHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } - public void Help() - { - Console.WriteLine("Help: Done\n"); - Console.WriteLine("Function: Mark a task as done"); - Console.WriteLine("Syntax: [id] done"); - } - public void Run(DoneCommand command) { TaskItem taskItem = _taskRepository.GetTaskById(command.Id); diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs index a2fe09e..5762527 100644 --- a/BusyList/Handlers/HelpHandler.cs +++ b/BusyList/Handlers/HelpHandler.cs @@ -36,9 +36,13 @@ public void Run(HelpCommand command) if (description != null && syntax != null) { - Console.WriteLine(command.name); - Console.WriteLine(description); - Console.WriteLine(syntax); + Console.WriteLine($"Command: {command.name}"); + Console.WriteLine($"Description: {description}"); + Console.WriteLine($"Syntax: {syntax}"); + } + else + { + Console.WriteLine($"Help for the command '{command.name}' does not exists"); } } } diff --git a/BusyList/Handlers/IHandler.cs b/BusyList/Handlers/IHandler.cs index 9f17a4c..b6e5c4a 100644 --- a/BusyList/Handlers/IHandler.cs +++ b/BusyList/Handlers/IHandler.cs @@ -5,11 +5,5 @@ namespace BusyList.Handlers public interface IHandler where TCommand : Command { void Run(TCommand command); - void Help(); - } - - internal interface IHelpHandler - { - void Run(IHandler handler) where TCommand : Command; } } diff --git a/BusyList/Handlers/NextHandler.cs b/BusyList/Handlers/NextHandler.cs index 31ae1e2..f85b370 100644 --- a/BusyList/Handlers/NextHandler.cs +++ b/BusyList/Handlers/NextHandler.cs @@ -1,8 +1,11 @@ using BusyList.Commands; +using BusyList.HelpSystem; using System; namespace BusyList.Handlers { + + [HelpAttribute("next", "Lists all tasks", "next")] public class NextHandler : IHandler { private readonly ITaskRepository _taskRepository; @@ -29,12 +32,5 @@ public void Run(NextCommand command) Console.WriteLine(SEPERATOR); } } - - public void Help() - { - Console.WriteLine("Help: Next\n"); - Console.WriteLine("Function: Lists all tasks with the id, description and status"); - Console.WriteLine("Syntax: [id]"); - } } } diff --git a/BusyList/Handlers/ReadHandler.cs b/BusyList/Handlers/ReadHandler.cs index b6700c9..50c5764 100644 --- a/BusyList/Handlers/ReadHandler.cs +++ b/BusyList/Handlers/ReadHandler.cs @@ -1,8 +1,10 @@ using BusyList.Commands; +using BusyList.HelpSystem; using System; namespace BusyList.Handlers { + [HelpAttribute("read", "Print the id, description and status of the task with the passed id", "[Id]")] public class ReadHandler : IHandler { private readonly ITaskRepository _taskRepository; @@ -12,13 +14,6 @@ public ReadHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } - public void Help() - { - Console.WriteLine("Help: Read\n"); - Console.WriteLine("Function: Give a task by id with the id, the description and the status"); - Console.WriteLine("Syntax: [id]"); - } - public void Run(ReadCommand command) { var task = _taskRepository.GetTaskById(command.Id); From b36491ecdee15c652b3381c5143b74f03038bd98 Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Tue, 25 May 2021 19:56:46 +0200 Subject: [PATCH 3/7] applied changes --- BusyList/Handlers/AddHandler.cs | 7 ------- BusyList/Parsing/CommandGrammar.cs | 4 ---- 2 files changed, 11 deletions(-) diff --git a/BusyList/Handlers/AddHandler.cs b/BusyList/Handlers/AddHandler.cs index 9dc8de5..589cd7d 100644 --- a/BusyList/Handlers/AddHandler.cs +++ b/BusyList/Handlers/AddHandler.cs @@ -15,13 +15,6 @@ public AddHandler(ITaskRepository taskRepository) _taskRepository = taskRepository; } - public void Help() - { - Console.WriteLine("Help: Add\n"); - Console.WriteLine("Function: Create a new task with the given description"); - Console.WriteLine("Syntax: add [id]"); - } - public void Run(AddCommand command) { var item = new AddTaskData(command.Description); diff --git a/BusyList/Parsing/CommandGrammar.cs b/BusyList/Parsing/CommandGrammar.cs index b6f99c2..1b66ab6 100644 --- a/BusyList/Parsing/CommandGrammar.cs +++ b/BusyList/Parsing/CommandGrammar.cs @@ -53,10 +53,6 @@ from _ in Parse.WhiteSpace from keyword in _keywordDone select new DoneCommand(id); - private static readonly Parser _overviewHelpCommand = - from keyword in _keywordHelp - select new HelpCommand(null); - private static readonly Parser _helpCommand = from keyword in _keywordHelp select new HelpCommand(); From 825bef0c0e97f8e84da804e915e9c5429d456493 Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Wed, 26 May 2021 14:59:56 +0200 Subject: [PATCH 4/7] Change help method of helphandler --- BusyList/Handlers/HelpHandler.cs | 12 ++++++------ BusyList/HelpSystem/HelpProvider.cs | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs index 5762527..8deb5ff 100644 --- a/BusyList/Handlers/HelpHandler.cs +++ b/BusyList/Handlers/HelpHandler.cs @@ -15,12 +15,12 @@ public HelpHandler(HelpProvider helpProvider) public void Help() { - Console.WriteLine("Commands:\n"); - Console.WriteLine("done - mark a task as done"); - Console.WriteLine("delete - delete a task"); - Console.WriteLine("next - list all tasks"); - Console.WriteLine("read - print the id, description and status of a task\n"); - Console.WriteLine("For more details do: help [keyword] e.g help done"); + var helpTexts = _helpProvider.GetAllHelpText(); + + foreach (var helpText in helpTexts) + { + Console.WriteLine($"{helpText.Item1}: {helpText.Item2}"); + } } public void Run(HelpCommand command) diff --git a/BusyList/HelpSystem/HelpProvider.cs b/BusyList/HelpSystem/HelpProvider.cs index e60b55b..6e19f74 100644 --- a/BusyList/HelpSystem/HelpProvider.cs +++ b/BusyList/HelpSystem/HelpProvider.cs @@ -16,6 +16,8 @@ public HelpProvider() .ToDictionary(x => x.Name.ToLowerInvariant(), x => (x.Description, x.Syntax)); } + public (string, string)[] GetAllHelpText() => _helpText.Select(x => (x.Key, x.Value.Item1)).ToArray(); + public (string, string) GetHelpText(string key) { if(_helpText.TryGetValue(key, out var value)) From dcad83fe56f1b4cfae6f5619c7b4c5d65a1eeca9 Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Wed, 26 May 2021 15:00:43 +0200 Subject: [PATCH 5/7] Change help method of helphandler --- BusyList/Handlers/HelpHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs index 8deb5ff..bdeea18 100644 --- a/BusyList/Handlers/HelpHandler.cs +++ b/BusyList/Handlers/HelpHandler.cs @@ -21,6 +21,8 @@ public void Help() { Console.WriteLine($"{helpText.Item1}: {helpText.Item2}"); } + + Console.WriteLine("For further information type help [keyword] e.g help add"); } public void Run(HelpCommand command) From 968f0a285751cc36089d4ab60569acf977fbf55e Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Wed, 26 May 2021 15:51:53 +0200 Subject: [PATCH 6/7] Apply changes --- BusyList/Handlers/HelpHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs index bdeea18..ea75a9a 100644 --- a/BusyList/Handlers/HelpHandler.cs +++ b/BusyList/Handlers/HelpHandler.cs @@ -17,9 +17,9 @@ public void Help() { var helpTexts = _helpProvider.GetAllHelpText(); - foreach (var helpText in helpTexts) + foreach (var (name, description) in helpTexts) { - Console.WriteLine($"{helpText.Item1}: {helpText.Item2}"); + Console.WriteLine($"{name}: {description}"); } Console.WriteLine("For further information type help [keyword] e.g help add"); From 9b6311b30dff5e79c5c5e51de4587452b504eece Mon Sep 17 00:00:00 2001 From: unbekanntunity Date: Thu, 27 May 2021 21:05:57 +0200 Subject: [PATCH 7/7] Apply changes --- BusyList/Handlers/HelpHandler.cs | 4 ++-- BusyList/HelpSystem/HelpProvider.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BusyList/Handlers/HelpHandler.cs b/BusyList/Handlers/HelpHandler.cs index ea75a9a..059d827 100644 --- a/BusyList/Handlers/HelpHandler.cs +++ b/BusyList/Handlers/HelpHandler.cs @@ -38,13 +38,13 @@ public void Run(HelpCommand command) if (description != null && syntax != null) { - Console.WriteLine($"Command: {command.name}"); + Console.WriteLine($"Command: {command.name.ToLowerInvariant()}"); Console.WriteLine($"Description: {description}"); Console.WriteLine($"Syntax: {syntax}"); } else { - Console.WriteLine($"Help for the command '{command.name}' does not exists"); + Console.WriteLine($"Help for the command '{command.name.ToLowerInvariant()}' does not exists"); } } } diff --git a/BusyList/HelpSystem/HelpProvider.cs b/BusyList/HelpSystem/HelpProvider.cs index 6e19f74..087c7b4 100644 --- a/BusyList/HelpSystem/HelpProvider.cs +++ b/BusyList/HelpSystem/HelpProvider.cs @@ -16,11 +16,11 @@ public HelpProvider() .ToDictionary(x => x.Name.ToLowerInvariant(), x => (x.Description, x.Syntax)); } - public (string, string)[] GetAllHelpText() => _helpText.Select(x => (x.Key, x.Value.Item1)).ToArray(); + public (string, string)[] GetAllHelpText() => _helpText.Select(x => (x.Key.ToLowerInvariant(), x.Value.Item1)).ToArray(); public (string, string) GetHelpText(string key) { - if(_helpText.TryGetValue(key, out var value)) + if(_helpText.TryGetValue(key.ToLowerInvariant(), out var value)) { return value; }