Our first program demonstrates how to use command-line flags. Here’s the full source code:
This Ada program uses the GNAT.Command_Line package to handle command-line flags, which is similar to the flag package in the original example.
To experiment with the command-line flags program, first compile it and then run the resulting executable directly.
Note that if you omit flags, they automatically take their default values:
Trailing positional arguments can be provided after any flags:
Use -h or --help flags to get automatically generated help text for the command-line program:
If you provide a flag that wasn’t specified, the program will print an error message:
This Ada implementation provides similar functionality to the original example, allowing users to specify command-line options and parse them in the program.