with Ada.Text_IO, Ada.Exceptions;
package body Command_Line_Generic is
use Ada.Text_IO, Ada.Exceptions;
package Command_Type_Io is new Enumeration_IO (Command_Type);
use Command_Type_Io;
procedure Get_Command is
Command : Command_Type := Command_Type'first;
Continue_Reading : Boolean := True;
begin
Main :
loop
for index in Command_Type'range loop
Put (index);
New_Line;
end loop;
New_Line;
Read_Block : declare
Input_Text : String (1 .. 200) := (others => ' ');
Length : Integer := 0;
begin
Put ("Enter: ");
Flush;
Get_Line (Input_Text, Length);
New_Line;
Command := Command_Type'value (Input_Text (1 .. Length));
Continue_Reading := Handle_Command (Command);
exception
when Constraint_Error =>
Put_Line ("Wrong Input!");
New_Line;
when others =>
raise;
end Read_Block;
exit Main when Continue_Reading = False;
end loop Main;
exception
when Error : others =>
Put_Line ("Exception_Name: " & Ada.Exceptions.Exception_Name (Error));
Put_Line ("Exception_Message: " & Ada.Exceptions.Exception_Message (Error));
Put_Line ("Exception_Information: " & Ada.Exceptions.Exception_Information (Error));
end Get_Command;
end Command_Line_Generic;