awa_unit_2.4.0_59135a52/openapi-ada/regtests/client/src/testapi-client.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
with TestAPI.Clients;
with TestAPI.Models;
with Swagger;
with Util.Http.Clients.Curl;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Calendar.Formatting;
with Ada.Exceptions;
procedure TestAPI.Client is

   use Ada.Text_IO;

   procedure Usage;

   Server : constant Swagger.UString :=
     Swagger.To_UString ("http://localhost:8080/v2");
   Arg_Count : constant Natural := Ada.Command_Line.Argument_Count;
   Arg       : Positive         := 1;

   procedure Usage is
   begin
      Put_Line ("Usage: TestAPI {params}...");
   end Usage;

begin
   if Arg_Count <= 1 then
      Usage;
      return;
   end if;
   Util.Http.Clients.Curl.Register;
   declare
      Command : constant String := Ada.Command_Line.Argument (Arg);
      Item    : constant String := Ada.Command_Line.Argument (Arg + 1);
      C       : TestAPI.Clients.Client_Type;
   begin
      C.Set_Server (Server);
      Arg := Arg + 2;

   exception
      when E : Constraint_Error =>
         Put_Line
           ("Constraint error raised: " &
            Ada.Exceptions.Exception_Message (E));

   end;
end TestAPI.Client;