-- This program illustrates accessing command line arguments
--
-- Run the program with and without arguments, for example
--    cmdline arg1 arg2
--    cmdline to be or not to be
--    cmdline
-- Then try renaming the executable, as in: mv cmdline newname

with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;

with ada.command_line; -- use ada.command_line;
--  Commenting out the use statement, forces the full
--  name to always be included.  This highlights the
--  routines that come from ada.command_line

procedure cmdline is

    -- package cl renames ada.command_line;
    -- If you uncomment the line above, then you can save some typing and
    -- use the name cl instead of ada.command_line, as in cl.argument_count

begin
    put_line("Argument_Count: " & ada.command_line.argument_count'img);
    -- Output the number of command line arguments


    -- Output each command line argument
    put_line("The Arguments are:");
    for i in 1 .. ada.command_line.argument_count loop
        set_col(5);  -- Start printing in column 5
        put_line(ada.command_line.argument(i));
    end loop;


    put_line("The name of the command is: " & ada.command_line.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;