From f5dd85e38c6b601ba1acbb59e57e76865aa3dca7 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Mon, 25 Apr 2022 11:15:23 +0200 Subject: [PATCH] Update `Console.Commander.NET` to the newest version --- .../HyperbolicDownloader.csproj | 2 +- HyperbolicDownloader/InputHandler.cs | 39 ++++++++++--------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/HyperbolicDownloader/HyperbolicDownloader.csproj b/HyperbolicDownloader/HyperbolicDownloader.csproj index 101fc76..ec11e23 100644 --- a/HyperbolicDownloader/HyperbolicDownloader.csproj +++ b/HyperbolicDownloader/HyperbolicDownloader.csproj @@ -12,7 +12,7 @@ - + diff --git a/HyperbolicDownloader/InputHandler.cs b/HyperbolicDownloader/InputHandler.cs index 038ccb7..c18a2b8 100644 --- a/HyperbolicDownloader/InputHandler.cs +++ b/HyperbolicDownloader/InputHandler.cs @@ -20,30 +20,31 @@ internal class InputHandler DownloadCommands downloadCommands = new DownloadCommands(hostsManager, filesManager); ClientCommands clientCommands = new ClientCommands(); - commander.Register((_) => Console.Clear(), "clear", "cls"); - commander.Register((_) => exit = true, "exit", "quit"); - commander.Register(clientCommands.ShowInfo, "info", "inf"); - commander.Register(hostCommands.Discover, "discover", "disc"); + commander.Register(input => commander.PrintHelp(input), "help"); + commander.Register(_ => Console.Clear(), (HelpText)"Clears the console.", "clear", "cls"); + commander.Register(_ => exit = true, (HelpText)"Exits the application.", "exit", "quit"); + commander.Register(clientCommands.ShowInfo, (HelpText)"Displays the private and public IP address.", "info", "inf"); + commander.Register(hostCommands.Discover, (HelpText)"Tries to find other active hosts on the local network.", "discover", "disc"); - Command getCommand = commander.Register(downloadCommands.GetFile, "get"); - getCommand.Register(downloadCommands.GetFileFrom, "from"); + Command getCommand = commander.Register(downloadCommands.GetFile, (HelpText)"Attempts to retrieve a file from another host using a hash.", "get"); + getCommand.Register(downloadCommands.GetFileFrom, (HelpText)"Attempts to retrieve a file from another host using a .hyper file.", "from"); - Command generateCommad = commander.Register(fileCommands.GenerateFileFull, "generate", "gen"); - generateCommad.Register(fileCommands.GenerateFileSingle, "noscan"); + Command generateCommad = commander.Register(fileCommands.GenerateFileFull, (HelpText)"Generates a .hyper file from a file hash.", "generate", "gen"); + generateCommad.Register(fileCommands.GenerateFileSingle, (HelpText)"Generates a .hyper file from a file hash without checking the known hosts. This adds only the local host to the file.", "noscan"); - Command addCommand = commander.Register(fileCommands.AddFile, "add"); - addCommand.Register(hostCommands.AddHost, "host"); - addCommand.Register(fileCommands.AddFile, "file"); + Command addCommand = commander.Register(fileCommands.AddFile, (HelpText)"Adds a file to the tracking list.", "add"); + addCommand.Register(fileCommands.AddFile, (HelpText)"Adds a file to the tracking list.", "file"); + addCommand.Register(hostCommands.AddHost, (HelpText)"Adds a host to the list of known hosts.", "host"); - Command removeCommand = commander.Register(fileCommands.RemoveFile, "remove", "rm"); - removeCommand.Register(hostCommands.RemoveHost, "host"); - removeCommand.Register(fileCommands.RemoveFile, "file"); + Command removeCommand = commander.Register(fileCommands.RemoveFile, (HelpText)"Removes a file from the tracking list.", "remove", "rm"); + removeCommand.Register(fileCommands.RemoveFile, (HelpText)"Removes a file from the tracking list.", "file"); + removeCommand.Register(hostCommands.RemoveHost, (HelpText)"Removes a host from the list of known hosts.", "host"); - Command listCommand = commander.Register(fileCommands.ListFiles, "list", "ls"); - listCommand.Register(fileCommands.ListFiles, "files"); - listCommand.Register(hostCommands.ListHosts, "hosts"); + Command listCommand = commander.Register(fileCommands.ListFiles, (HelpText)"Lists all files.", "list", "ls"); + listCommand.Register(fileCommands.ListFiles, (HelpText)"Lists all files.", "files"); + listCommand.Register(hostCommands.ListHosts, (HelpText)"lists all hosts.", "hosts"); - commander.Register(hostCommands.CheckActiveHosts, "status", "check"); + commander.Register(hostCommands.CheckActiveHosts, (HelpText)"Checks the status of known hosts.", "status", "check"); } public void ReadInput() @@ -59,7 +60,7 @@ internal class InputHandler Console.CursorVisible = false; try { - if (!commander.Execute(input)) + if (!commander.Execute(input, out _)) { ConsoleExt.WriteLine("Unknown command!", ConsoleColor.Red); }