A test script written in Perl to parse command line arguments and output different things depending on the option entered.
- Author: Ethan Kletschke
- Version:
1.2.2(DEPRECATED) - Developed on: Windows 11
- License: MIT
This project is now deprecated. No further updates will happen unless someone else takes over.
The Perl Command Line Parser is a simple command-line interface (CLI) app (esssentially just a test script) that parses command line arguments passed to the program. It is only intended to be a skills reference, and as a test to see how the Perl language works when used for a simple software application.
The table below lists the currently-implemented valid command-line arguments:
| Option | Description |
|---|---|
-v/--version |
Displays version information. |
-h/--help |
Help menu. Also displays on incorrect CLI input (see here). |
-Dall |
Short for Display all. Turns on "verbosity mode", which displays both debug messages and warnings. |
-Dbug |
Short for Display debug. Turns on debugging messages. |
-Dwarn |
Short for Display warnings. Turns on warning messages. |
(Table generated with TablesGenerator.com)
The table below lists the planned options that could be implemented in later versions of this "app":
| Option | Description | Planned Version* |
|---|---|---|
-m "Literal" |
Displays the string "Literal" that comes immediately after the -m flag. |
1.3 |
--message "Literal" |
Alias of -m. |
1.3 |
-l |
Log the output to a file. | 1.3 |
--log |
Alias of -l |
1.3 |
-s |
Save output to a file(?). | ??? |
--save |
Alias of -s. |
??? |
* - Not 100% accurate.
(Table generated with TablesGenerator.com)
If the user enters a single-output option (such as -v or -h) along with more than one option, then the program will
close with an error message.
Or if the user enters a normal flag (such as -Dall) as the only option (as of v1.1), the program will close with an error
message.
For example:
perl Main.pl -DallWill show the following output (as of v1.1):
Single-line flag not entered.
Exiting...
- Documentation updates:
- Add MIT
LICENSEfile. - Tweak
README.md
- Add MIT
Stop working on project.
- Implementation Tweaks:
- Add more comments.
- Tweak flag setting:
- Set all flags at once when testing for multiple flags, i.e. setting
$verboseand unsetting the other flags.
- Set all flags at once when testing for multiple flags, i.e. setting
New Features:
- Allow
--versionto be used as an alias of-v. - Allow
--helpto be used as an alias of-h.
Implementation Tweaks:
- Re-ordered the
$helpstring's list to show single-line flags first.
Bug fixes:
- Tweaked
ifstatements to actually allow for warning outputs to be enabled. - Tweaked single-argument handling a bit.
- Temporarily use the
diekeyword to kill the program when a single-line flag is not entered.- To be fixed in a future release.
- Temporarily use the
- Fix
README.md- Add missing heading "Incorrect CLI Output".
- Add various new sections.
Program is initially released onto Github.