Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

34 help command #38

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions BusyList/Handlers/HelpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public HelpHandler(HelpProvider helpProvider)

public void Help()
pobiega marked this conversation as resolved.
Show resolved Hide resolved
{
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)
pobiega marked this conversation as resolved.
Show resolved Hide resolved
{
Console.WriteLine($"{helpText.Item1}: {helpText.Item2}");
}

Console.WriteLine("For further information type help [keyword] e.g help add");
}

public void Run(HelpCommand command)
Expand Down
2 changes: 2 additions & 0 deletions BusyList/HelpSystem/HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down