diff --git a/HyperbolicDownloader/InputHandler.cs b/HyperbolicDownloader/InputHandler.cs index 0863b49..c3bd8d1 100644 --- a/HyperbolicDownloader/InputHandler.cs +++ b/HyperbolicDownloader/InputHandler.cs @@ -22,7 +22,7 @@ internal class InputHandler ClientCommands clientCommands = new ClientCommands(); LogCommands logCommands = new LogCommands(); - _ = commander.Register(input => commander.PrintHelp(input), "help"); + _ = commander.Register(input => commander.PrintHelp(input), (HelpText)"Lists all commands.", "help", "h", "?"); _ = 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"); @@ -66,19 +66,23 @@ internal class InputHandler Console.CursorVisible = true; string input = Console.ReadLine()?.Trim() ?? string.Empty; + ExecuteInput(input); + } + } - Console.CursorVisible = false; - try + public void ExecuteInput(string input) + { + Console.CursorVisible = false; + try + { + if (!commander.Execute(input, out _)) { - if (!commander.Execute(input, out _)) - { - ConsoleExt.WriteLine("Unknown command!", ConsoleColor.Red); - } - } - catch (Exception ex) - { - ConsoleExt.WriteLine($"An unexpected error occurred! {ex}", ConsoleColor.Red); + ConsoleExt.WriteLine("Unknown command! Use `help` to list all commands.", ConsoleColor.Red); } } + catch (Exception ex) + { + ConsoleExt.WriteLine($"An unexpected error occurred! {ex}", ConsoleColor.Red); + } } } \ No newline at end of file diff --git a/HyperbolicDownloader/Program.cs b/HyperbolicDownloader/Program.cs index 5e288c2..1110a07 100644 --- a/HyperbolicDownloader/Program.cs +++ b/HyperbolicDownloader/Program.cs @@ -53,12 +53,15 @@ internal static class Program { HyperbolicDownloaderApi.Commands.DownloadCommands downloadCommands = new HyperbolicDownloaderApi.Commands.DownloadCommands(apiManager.HostsManager, apiManager.FilesManager); downloadCommands.GetFileFrom(args[0]); - Console.WriteLine("Do you want to continue using this instance? [y/N]"); - if (char.ToLower(Console.ReadKey().KeyChar) != 'y') - { - return; - } + _ = Console.ReadLine(); + return; + } + else if (args.Length > 0) + { + ConsoleExt.WriteLine("Warning! You are using command line arguments, which can lead to unexpected behavior with some commands.", ConsoleColor.Yellow); Console.WriteLine(); + inputHandler.ExecuteInput(string.Join(' ', args)); + return; } await Initialize();