-- Example to try the command line arguments
with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;
with ada.command_line;
-- As an example, omit the use statement
-- Without a use statement, the full package name must be used,
-- but see the renames below.
procedure cmdline is
package cl renames ada.command_line;
-- The name cl can be used in place of the name ada.command_line
-- This saves us from having to type the full name: ada.command_line
begin
put_line("Argument_Count: " & cl.argument_count'img);
-- Output the number of command line arguments
-- Output each command line argument
put_line("The Arguments are:");
for i in 1 .. cl.argument_count loop
set_col(5); -- Start printing in column 5
put_line(cl.argument(i));
end loop;
put_line("The name of the command is: " & cl.command_name);
-- Print the name of the command used to execute this program.
-- Normally this would be the name of the procedure, but the name of the
-- executable might have been be changed (eg mv cmdline othername).
end cmdline;