commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard (Jira)" <>
Subject [jira] [Commented] (CLI-298) Define CLI options via configuration file
Date Fri, 18 Oct 2019 11:07:00 GMT


Richard commented on CLI-298:

Dear Apaches,

I am continuing work on this project and it's bearing some sweet, sweet fruit for myself.

However, the overall impression is that you're not overly keen on accepting my changes for
the reasons you've specified. In which case, I am beginning to think I should fork off (pun
intended) and create my own project for this purpose. Please let me know if you think that
I should do this.

Otherwise, here's the latest examples of the changes I've made.

Data types are now catered for - at the moment, integers, floats, string (matching), files.
Some examples:
{code:java|title=Bad String Match|borderStyle=solid}
option.md5.description=MD5 to test against the file.
Running this with -m produces:
my-command -m bad-md5_value
Error: option m: Data 'bad-md5_value' is an invalid format.
{code:java|title=Show File Errors|borderStyle=solid}
option.file.description=Command line configuration file to parse.
Running this with -f produces:
my-command -f /tmp
Error: option f: Specified file /tmp is a directory (expected file).
my-command -f
Error: option f: Specified file does not exist.
We can change the above properties to !exists:
{code:java|title=File Must Not Exist|borderStyle=solid}!exists
... to get:
my-command -f pom.xml
Error: option f: Specified file pom.xml already exists.
An integer example:
{code:java|title=Integer-based Errors|borderStyle=solid}
option.port.description=Port number.
my-command -f pom.xml
Error: option p: 40 is less than specified minimum: 80
In all cases, the value updated to the listener is the type specified by the configuration
- so a java.lang.Integer, String, etc.

Some of our tools work like git in that they take the form "command sub-command [options].
I'll definitely be updating the configuration to take sub-commands that each have their own
options. In fact there's many things I'd like to incorporate, but I guess that's for another

I appreciate the feedback you've given and thanks for your time. If I don't hear from you
within a week, thanks for your time and I'll be on my merry way.

Hoka Hey!

(OK so I know that's Lakota, but it's the only plains Indian I know...)

> Define CLI options via configuration file
> -----------------------------------------
>                 Key: CLI-298
>                 URL:
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Options definition
>    Affects Versions: 1.5, Nightly Builds
>            Reporter: Richard
>            Priority: Minor
>              Labels: newbie, pull-request-available, ready-to-commit
>   Original Estimate: 336h
>  Remaining Estimate: 336h
> Create a configuration that enables users to define CLI options via a configuration file.
Such configuration would normally pre-defined and bundled inside the executable jar running
the application. This would reduce the amount of code required to define command line options
and introduce the ability to do a lot of the checking a user does (such as converting values
to integers, files, checking if integers are above/below a certain amount, checking that files
or directories do/don't exist etc.) For security purposes, at compile time calculate an MD5
for the application, if this doesn't match at runtime warn of corrupted file exception. Also
add I18N since this will be driven via the user experience for exception messages.
> So far I've catered for basic options that utilise strings.
> Code already started with a pull request at []
underneath the branch named "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.

This message was sent by Atlassian Jira

View raw message