正如使用 Ada.Command_Line 已经说过的那样,我会建议类似的东西:
with
Ada.Text_IO,
Ada.Command_Line,
Ada.Strings.Bounded;
use
Ada.Text_IO,
Ada.Command_Line;
procedure Main is
package SB is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => 100);
use SB;
Cur_Argument : SB.Bounded_String;
Input_File_Path : SB.Bounded_String;
Output_File_Path : SB.Bounded_String;
I : Integer := 1;
begin
-- For all the given arguments
while I < Argument_Count loop
Cur_Argument := SB.To_Bounded_String(Argument(I));
if Cur_Argument = "U" or Cur_Argument = "u"
then
-- stuff for uppercase
elsif Cur_Argument = "L" or Cur_Argument = "l"
then
-- stuff for lowercase
elsif Cur_Argument = "i"
then
-- following one is the path of the file
Input_File_Path := SB.To_Bounded_String(Argument(I+1));
i := i + 1;
elsif Cur_Argument = "o"
then
Output_File_Path := SB.To_Bounded_String(Argument(I+1));
i := i + 1;
else
Put_Line("Wrong arguments");
end if;
i := i + 1;
end loop;
end Main;