22
33using HyperbolicDownloaderApi . Commands ;
44using HyperbolicDownloaderApi . FileProcessing ;
5+ using HyperbolicDownloaderApi . Networking ;
56
67using Stone_Red_Utilities . ConsoleExtentions ;
78
8- namespace HyperbolicDownloaderApi ;
9+ namespace HyperbolicDownloader ;
910
1011internal class InputHandler
1112{
12- private readonly HostsManager hostsManager ;
1313 private readonly Commander commander = new Commander ( ) ;
1414 private bool exit = false ;
1515
@@ -20,32 +20,31 @@ public InputHandler(HostsManager hostsManager, FilesManager filesManager)
2020 DownloadCommands downloadCommands = new DownloadCommands ( hostsManager , filesManager ) ;
2121 ClientCommands clientCommands = new ClientCommands ( ) ;
2222
23- this . hostsManager = hostsManager ;
23+ _ = commander . Register ( input => commander . PrintHelp ( input ) , "help" ) ;
24+ _ = commander . Register ( _ => Console . Clear ( ) , ( HelpText ) "Clears the console." , "clear" , "cls" ) ;
25+ _ = commander . Register ( _ => exit = true , ( HelpText ) "Exits the application." , "exit" , "quit" ) ;
26+ _ = commander . Register ( clientCommands . ShowInfo , ( HelpText ) "Displays the private and public IP address." , "info" , "inf" ) ;
27+ _ = commander . Register ( hostCommands . Discover , ( HelpText ) "Tries to find other active hosts on the local network." , "discover" , "disc" ) ;
2428
25- commander . Register ( ( _ ) => Console . Clear ( ) , "clear" , "cls" ) ;
26- commander . Register ( Exit , "exit" , "quit" ) ;
27- commander . Register ( clientCommands . ShowInfo , "info" , "inf" ) ;
28- commander . Register ( hostCommands . Discover , "discover" , "disc" ) ;
29+ Command getCommand = commander . Register ( downloadCommands . GetFile , ( HelpText ) "Attempts to retrieve a file from another host using a hash." , "get" ) ;
30+ _ = getCommand . Register ( downloadCommands . GetFileFrom , ( HelpText ) "Attempts to retrieve a file from another host using a .hyper file." , "from" ) ;
2931
30- Command getCommand = commander . Register ( downloadCommands . GetFile , "get ") ;
31- getCommand . Register ( downloadCommands . GetFileFrom , " from") ;
32+ Command generateCommad = commander . Register ( fileCommands . GenerateFileFull , ( HelpText ) "Generates a .hyper file from a file hash." , "generate" , "gen ") ;
33+ _ = 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 ") ;
3234
33- Command generateCommad = commander . Register ( fileCommands . GenerateFileFull , "generate" , "gen" ) ;
34- generateCommad . Register ( fileCommands . GenerateFileSingle , "noscan" ) ;
35+ Command addCommand = commander . Register ( fileCommands . AddFile , ( HelpText ) "Adds a file to the tracking list." , "add" ) ;
36+ _ = addCommand . Register ( fileCommands . AddFile , ( HelpText ) "Adds a file to the tracking list." , "file" ) ;
37+ _ = addCommand . Register ( hostCommands . AddHost , ( HelpText ) "Adds a host to the list of known hosts." , "host" ) ;
3538
36- Command addCommand = commander . Register ( fileCommands . AddFile , "add ") ;
37- addCommand . Register ( hostCommands . AddHost , "host ") ;
38- addCommand . Register ( fileCommands . AddFile , "file ") ;
39+ Command removeCommand = commander . Register ( fileCommands . RemoveFile , ( HelpText ) "Removes a file from the tracking list." , "remove" , "rm ") ;
40+ _ = removeCommand . Register ( fileCommands . RemoveFile , ( HelpText ) "Removes a file from the tracking list." , "file ") ;
41+ _ = removeCommand . Register ( hostCommands . RemoveHost , ( HelpText ) "Removes a host from the list of known hosts." , "host ") ;
3942
40- Command removeCommand = commander . Register ( fileCommands . RemoveFile , "remove ", "rm " ) ;
41- removeCommand . Register ( hostCommands . RemoveHost , "host ") ;
42- removeCommand . Register ( fileCommands . RemoveFile , "file ") ;
43+ Command listCommand = commander . Register ( fileCommands . ListFiles , ( HelpText ) "Lists all files. ", "list" , "ls ") ;
44+ _ = listCommand . Register ( fileCommands . ListFiles , ( HelpText ) "Lists all files." , "files ") ;
45+ _ = listCommand . Register ( hostCommands . ListHosts , ( HelpText ) "lists all hosts." , "hosts ") ;
4346
44- Command listCommand = commander . Register ( fileCommands . ListFiles , "list" , "ls" ) ;
45- listCommand . Register ( fileCommands . ListFiles , "files" ) ;
46- listCommand . Register ( hostCommands . ListHosts , "hosts" ) ;
47-
48- commander . Register ( hostCommands . CheckActiveHosts , "status" , "check" ) ;
47+ _ = commander . Register ( hostCommands . CheckActiveHosts , ( HelpText ) "Checks the status of known hosts." , "status" , "check" ) ;
4948 }
5049
5150 public void ReadInput ( )
@@ -61,7 +60,7 @@ public void ReadInput()
6160 Console . CursorVisible = false ;
6261 try
6362 {
64- if ( ! commander . Execute ( input ) )
63+ if ( ! commander . Execute ( input , out _ ) )
6564 {
6665 ConsoleExt . WriteLine ( "Unknown command!" , ConsoleColor . Red ) ;
6766 }
@@ -72,10 +71,4 @@ public void ReadInput()
7271 }
7372 }
7473 }
75-
76- private void Exit ( string _ )
77- {
78- hostsManager . SaveHosts ( ) ;
79- exit = true ;
80- }
8174}
0 commit comments