Suppose I have a tool which uses org.apache.commons.cli package to take command line options. I define an option
Options opts = new Options(); opts.addOption("v", "version", false, "print tool version information");
So the user can call my tool with -v or with --version command line options.
The question is, can I then tell in my code if the user typed -v or --version?
What I am thinking is to associate long versions of command line options with verbose output, and short versions with non-verbose. So, if a user passes -v, he/she will get version number of the tool, but if a user types --version, he/she will get version of the tool, versions of dependencies, some other versioning and vendor info, etc.
- Can it be done with org.apache.commons.cli effectively?
- Is it a good idea from the user perspective? Is this a common practice or am I inventing something esoteric here?
Experienced thought on both implementation and the philosophy of this approach are appreciated.
Thanks in advance