-- Test example showing how to use GETOPT Ada package -- Nasser M. Abbasi nma@12000.org with Ada.Text_Io; use Ada.Text_Io; with Ada.Command_Line; use Ada.Command_Line; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Getopt; procedure Test_Getopt is Test_String : String := "c:di:n:p:u:V"; Optchar : character; Value : Integer; begin Getopt.Opterr := 1; loop Value := Getopt.Getopt( Test_String ); exit when Value = -1; optchar := Character'Val( Value ); case optchar is when 'c' => Put_Line("commant is "& To_String(Getopt.Optarg)); when 'd' => Put_Line("debug on"); when 'i' => Put_line("got -i, its argument is:" & To_String(Getopt.Optarg) ); when 'n' => Put_line("got -n, its argument is:" & To_String(Getopt.Optarg)); when 'p' => Put_line("got -p, its argument is:" & To_String(Getopt.Optarg)); when 'u' => Put_line("got -u, its argument is:" & To_String(Getopt.Optarg)); when 'V' => Put_line("got -V"); when '?' => Put_Line("got ?, optopt is " & Getopt.Optopt); when ':' => Put_Line("get :, optopt is "& Getopt.optopt); when others => null; end case; end loop; -- now lets print the remaining arguments if any declare Index : positive; begin Index := Getopt.Optind; for I in Index..Argument_Count loop Put_Line( Argument(I) ); end loop; end; end Test_Getopt;