-- Demonstrates using 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; 

procedure cmdline is
    -- A renames helps show what's in the package without too much typing
    package cl renames ada.command_line;
begin
    -- Output the name of the command
    put_line("The name of the command is: " & cl.command_name);
    -- Remember that the executable can be renamed

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

    -- Output each command line argument
    -- Each argument is a string
    put_line("The Arguments are:");
    for i in 1 .. cl.argument_count loop
        set_col(5);
        put(i, 2);
        put_line(": <" & cl.argument(i) & ">");
    end loop;
end cmdline;

-- Sample run: > cmdline The cat sat, on 25 mats!
-- Output:
--|The name of the command is: cmdline
--|Argument_Count:  6
--|The Arguments are:
--|     1: <The>
--|     2: <cat,>
--|     3: <sat>
--|     4: <on>
--|     5: <25>
--|     6: <mats!>