Hosted by
|
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Text_IO; use Ada.Text_IO;
with Strings; use Strings;
with String_Tools; use String_Tools;
package body Messages is
Program_Name : String_Access;
Quiet : Boolean := False;
procedure Debug
(Text : in String) is
begin
Put_Line(Ada.Text_IO.Current_Error, Text);
end Debug;
procedure Debug2
(Text : in String) is
begin
Put(Ada.Text_IO.Current_Error, Text);
end Debug2;
procedure Message
(Text : in String) is
begin
if not Quiet then
if not Is_Null(Program_Name)
then Put_Line(Ada.Text_IO.Current_Error, To_String(Program_Name) & ": " & Text);
else Put_Line(Ada.Text_IO.Current_Error, Text);
end if;
end if;
end Message;
procedure Error
(Text : in String) is
begin
if not Is_Null(Program_Name)
then Put_Line(Ada.Text_IO.Current_Error, To_String(Program_Name) & ": " & Text);
else Put_Line(Ada.Text_IO.Current_Error, Text);
end if;
Set_Exit_Status(Failure);
end Error;
procedure Error
(E : in Exception_Occurrence)
is
Name : String := Suffix_After_Char(Exception_Name(E), '.');
Message : String := Exception_Message(E);
begin
To_Lower(Name);
Replace_Char(Name, '_', ' ');
Error(Name & ": " & Message);
end Error;
procedure Set_Program_Name
(Program_Name : in String) is
begin
To_String_Access(Program_Name, Messages.Program_Name);
end Set_Program_Name;
function Get_Program_Name
return String is
begin
return To_String(Program_Name);
end Get_Program_Name;
procedure Set_Quiet
(Quiet : in Boolean) is
begin
Messages.Quiet := Quiet;
end Set_Quiet;
function Get_Quiet
return Boolean is
begin
return Quiet;
end Get_Quiet;
end Messages;
|