[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-21 Thread Michael Osipov (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16956444#comment-16956444
 ] 

Michael Osipov commented on CLI-298:


W/o having read this discussion or the PR, I strong recommend doing it with 
{{@files}} just like all Java commands, Python's argparse or {{eclipse.ini}} 
do. One component per line in the file. The approach would be instantly 
recognized by most devs.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-18 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16954507#comment-16954507
 ] 

Richard commented on CLI-298:
-

I forgot to metion - without having to do anything else, running -h produces:
{code:java}
usage: md5-check
Print the MD5 of the specified file, checking if it is equal to the
specified MD5 string.
 -d,--directoryDirectory to scan.
 -f,--fileCommand line configuration file to parse.
 -h,--help  Print this help then quit.
 -m,--md5  MD5 to test against the file.
 -p,--port Port number.
Copyright 2019 Apache Software Foundation.
 {code}

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-18 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16954502#comment-16954502
 ] 

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.opts=m/md5
option.md5.hasArg=true
option.md5.properties=match=[a-zA-Z0-9]+
option.md5.description=MD5 to test against the file.
{code}
Running this with -m produces:
{code:java}
my-command -m bad-md5_value
Error: option m: Data 'bad-md5_value' is an invalid format.
{code}
{code:java|title=Show File Errors|borderStyle=solid}
option.file.opts=f/file
option.file.hasArg=true
option.file.argName=file
option.file.type=file
option.file.properties=file
option.file.description=Command line configuration file to parse.
{code}
Running this with -f produces:
{code:java}
my-command -f /tmp
Error: option f: Specified file /tmp is a directory (expected file).
my-command -f foo.bar.baz
Error: option f: Specified file foo.bar.baz does not exist.
{code}
We can change the above properties to !exists:
{code:java|title=File Must Not Exist|borderStyle=solid}
option.file.properties=!exists
{code}
... to get:
{code:java}
my-command -f pom.xml
Error: option f: Specified file pom.xml already exists.
{code}
An integer example:
{code:java|title=Integer-based Errors|borderStyle=solid}
option.port.opts=p/port
option.port.hasArg=true
option.port.type=int
option.port.properties=min=80,max=8080
option.port.description=Port number.
{code}
Example:
{code:java}
my-command -f pom.xml
Error: option p: 40 is less than specified minimum: 80
{code}
In all cases, the value updated to the listener is the type specified by the 
configuration - so a java.lang.Integer, String, java.io.File 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 time.

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: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953819#comment-16953819
 ] 

Richard commented on CLI-298:
-

The main reason we didn't switch to JCommander was that we already had our 
Apache CLI options already set. Converting to another format, even if it 
reduces the amount of code by a given amount, would still be back-breaking and 
take considerable time to convert from one to the other. The approach I've 
settled with will save me a lot of time, anyway. Plus we here have a lot of 
love for Apache Commons!

Please don't let CLI head to the attic, it's not where it's destined for...

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Gilles Sadowski (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953809#comment-16953809
 ] 

Gilles Sadowski commented on CLI-298:
-

bq. JCommander and picoli are already there and working nicely.

For components that are heading towards the attic, shouldn't it be mentioned on 
the web site, so that people don't waste their time (and are redirected to the 
appropriate places)?


> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953782#comment-16953782
 ] 

Gary D. Gregory commented on CLI-298:
-

My personal preference is to keep Commons CLI bare bones unless someone wants 
to take the annotations approach; but honestly, I do not know why anyone would 
want to do that when JCommander and picoli are already there and working nicely.


> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953776#comment-16953776
 ] 

Richard commented on CLI-298:
-

One other thing: I started this project with the intent of not modifying any of 
the main code. However, I am wondering once I've hooked in all the 
type-conversion formatting and checking for different types (ints, files etc.) 
that it might have application to be brought into the main code WRT configuring 
and coding CLI options.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953773#comment-16953773
 ] 

Richard commented on CLI-298:
-

OK should I just shelve this and maintain my own version? I don't want to waste 
your folks time posting here if you're not keen on my changes. Or I can go 
silent until I'm finished, update and you can see if it fits the bill.

You're right about the object model - as I stated, it's about reduction of the 
amount of code we write,  using this is an alternative to manually writing 
code, you just need your configuration file and about 20-30 lines of code - 
which is a great reduction of one of our applications. For example, there's one 
where the options and definitions with error checking arguments comes to just 
over 600 lines, and that's just one application! For all projects combined I 
imagine it's several thousand lines.

I'm not sure with my current example posted above that you see the benefit to 
using this as an alternative to manually writing options, so feel free to ask 
questions if you're not sure. Thanks for the feedback either way.

One important point: I'm not proposing these changes as a new and better way to 
use CLI - more that there's an alternative way if one wants to use it.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Emmanuel Bourg (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953758#comment-16953758
 ] 

Emmanuel Bourg commented on CLI-298:


I admit I'm not seduced either by the format proposed. There is a duplication 
between the options defined in the file and the options parsed in the listener. 
Also, the purpose of the listener seems mostly to be to build an object model 
equivalent to the command line arguments. This problem is more cleanly solved 
by an annotation based approach like JCommander.

We could get some inspiration from other CLI libraries but we would probably 
end up rewriting the same code. Unless we have a clever novel design idea I 
don't think it's worth rewriting what others have already done.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953756#comment-16953756
 ] 

Richard commented on CLI-298:
-

Agreed about text file format, for myself with the projects we're working on, 
once I've completed this, it will massively reduce code overhead because some 
of our CLI applications have dozens of options, and currently about to hit half 
a dozen for the amount of individual applications we maintain that use CLI. I'd 
love to see annotations too but this is more of a priority for myself at the 
moment.

Talking of which, how do you folks work here? My current section is now 
finished, and what's left (in no strict order) is:

* File corruption/modification detection;
* Add ability to coerce arguments to integers, floating point numbers, dates, 
files, IP addresses, URLs along with the ability to create your own builders; 
on top of this will be the ability to say that a file must exist, must be a 
directory, must not exist, check integer value limits etc. and add all the 
handling to print back to the user if there's a problem.;
* Expanding on the previous point, the ability to defines options as taking 
lists of any of the above e.g. \-\-portNums=80,8080,8081 etc;
* Add I18N since currently the user could be defining text to be output in 
their native language but currently errors will be reported in English;

So my question is shall I keep updating this task or create new tasks, also 
should I treat this as one pull request or do one per feature update? Happy to 
conform to your working standards.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953747#comment-16953747
 ] 

Gary D. Gregory commented on CLI-298:
-

I am not a fan of the text file format, it is too brittle, not type-safe, and 
too easy to mess up. 

I see annotations as the way forward here. 

External files are good for I18N of course. 

Sadly it seems to me that Commons CLI has really fallen behind the times, we 
should look for inspiration at JCommander http://jcommander.org/ and picocli 
https://picocli.info/ 

I've am currently using JCommander for new projects but still have some Commons 
CLI in older ones.


> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Emmanuel Bourg (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953741#comment-16953741
 ] 

Emmanuel Bourg commented on CLI-298:


MD5 is still fine if the purpose is to detect accidental corruption. It isn't 
if security is at stake.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953738#comment-16953738
 ] 

Gary D. Gregory commented on CLI-298:
-

Tangent (regardless of the merit of this ticket): Do not use MD5, it is broken, 
use SHA-256 or 512.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953607#comment-16953607
 ] 

Richard commented on CLI-298:
-

Strictly speaking I suppose they are properties files since (at the moment) all 
definition take the form x=y.

So right now they are configuration files that are property-based.

However, I am not sure if this will always hold since there are more phases to 
this to finish. For example adding builder and checkers to get values as 
integral values and checking that the values are correct according to 
user-defined 'properties'. This will greatly reduce the amount of code users 
have to write.

As it stands, I believe that future updates (I plan to finish this by the end 
of next week) will take the same form.

I assume that you're thinking that it would be worthwhile renaming the test 
files to .properties instead of .conf?

The reason I've not read them in as a properties file is that there's a strict 
format to which the options appear which I believe reading as a properties file 
would break.

What are your thoughts on this?

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Emmanuel Bourg (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953603#comment-16953603
 ] 

Emmanuel Bourg commented on CLI-298:


The config file is a properties file or a custom format?

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-17 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953597#comment-16953597
 ] 

Richard commented on CLI-298:
-

Tests updated, new test files added. Stricter parsing of options now enforces 
that they are defined in groups and options cannot have their members set more 
than once.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-16 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953192#comment-16953192
 ] 

Richard commented on CLI-298:
-

Oh dear,

 

I think markdown just smacked me in the face. Give me twenty minutes and I'll 
re-format it!

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-16 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190
 ] 

Richard commented on CLI-298:
-

Thanks Emmanuel,

Global option OPTION_TYPE is checked for re-definition; not sure that standard 
option.[name] types are or global HELP_* options are; if they're not, I'll 
update the tests tomorrow to cater for catching these exceptions.

WRT example of options, if you start with the javadoc for 
CommandLineConfiguration, it's all linked from there. But, for brevity, here 
goes:

Step 0: We're going to create a CLI configuration that supports \-f/\-\-file 
(file to write to), \-t/\-\-text (text to write to file) and \-o/\-\-overwrite 
--(overwrite file). In addition, we want the CLI configuration to deal with 
help printing for us.

Step 1: Create your CLI configuration in a file named opt.config:

{{HELP_OPTION_NAME=showHelp}}
{{ HELP_COMMAND_NAME=writeData}}
{{ HELP_COMMAND_HEADER=Write the specified text to the specified file. If the 
\}}
{{ options contain spaces or special characters, supply the arguments in \}}
{{ }}{{ double quotes.}}
{{ HELP_COMMAND_FOOTER=Copyleft Foo, Bar & Baz 
International.}}{{option.outfile.opts=f/file}}
{{ option.outfile.hasArg=true}}
{{ option.outfile.argName=file}}
{{ option.outfile.description=File to write 
to.}}{{option.textToWrite.opts=t/text}}
{{ option.textToWrite.hasArg=true}}
{{ option.textToWrite.argName=text}}
{{ option.textToWrite.description=Text to write to the 
file.}}{{option.writeover.opts=o/overwrite}}
{{}}{{option.writeover.description=If set, write over the existing file; \}}
{{ }}{{otherwise, append to the file.}}{{option.showHelp.opts=h/help}}
{{ option.showHelp.hasArg=false}}
{{ option.showHelp.description=Print this help then quit.}}

Step 2: Create an option listener:

{{public class MyOptionListener implements OptionListener}}

{{{}}

{{    public File outFile;}}

{{    }}{{public String text;}}

{{    }}{{public boolean overwrite;}}

{{    }}{{@Override}}

{{    }}{{public void option(final String option, final Object value)}}
{{    }}{{{}}
{{    }}{{ if ("help".equals(option))}}
{{}}{{}}{{{}}

{{    // Global HELP_* options at this point already printed so we quit 
here and exit gracefully}}
{{    }}{{    }}{{ System.exit(0);}}
{{    }}{{ }}}
{{    }}{{ else if ("file".equals(option))}}
{{    }}{{ {}}
{{    }}{{    }}{{ outFile = new File(value.toString());}}
{{    }}{{ }}}
{{    }}{{ else if ("text".equals(option))}}
{{    }}{{{}}
{{    }}{{    }}{{ text = value.toString();}}
{{    }}{{ }}}
{{    }}{{ else if ("overwrite".equals(option))}}
{{    }}{{ {}}
{{    }}{{    }}{{overwrite = true;}}
{{    }}{{ }}}
{{ }}}

Step 3: Call the API from a call to static void main(String[] args) - this 
example illustrates a pre-defined class named Application that has a call to 
write(File, String, boolean), but that's not really important - at this point 
we've processed all the arguments and can do what we like with them:

{{ MyOptionListener listener = new MyOptionListener(); }}

{{InputStream is = new FileInputStream(new File("opt.config")); }}

{{CommandLineConfiguration cliConfig = new CommandLineConfiguration();}}

{{ cliConfig.addOptionListener(listener); }}

{{// args[] from the public static void main(String[] args) call: }}

{{cliConfig.process(is, "UTF-8"args); }}

{{Application application = new Application(); }}

{{if (listener.file != null && listener.text != null) }}

{{}}

{{{}}

{{    }}{{application.write(listener.file, listener.text, listener.overwrite); 
}}

{{} }}

{{else}}

{{{}}

{{    System.err.println("File and text must be supplied.");
 System.exit(1);}}

{{}}}

 

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 

[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-16 Thread Emmanuel Bourg (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953167#comment-16953167
 ] 

Emmanuel Bourg commented on CLI-298:


Thank you for the contribution Richard. Could you give a short example of 
options defined with an external file? How do you avoid defining the options 
twice in the configuration file and in the code handling the option parsing?

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> 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 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CLI-298) Define CLI options via configuration file

2019-10-16 Thread Richard (Jira)


[ 
https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953125#comment-16953125
 ] 

Richard commented on CLI-298:
-

BTW, I had no idea what to affects/fix versions so if this seems erroneous you 
know why.

Help appreciated in filling this out correctly. I added the label newbie to 
emphasize this.

> Define CLI options via configuration file
> -
>
> Key: CLI-298
> URL: https://issues.apache.org/jira/browse/CLI-298
> Project: Commons CLI
>  Issue Type: Improvement
>  Components: CLI-2.x
>Affects Versions: 1.5
>Reporter: Richard
>Priority: Trivial
>  Labels: newbie, pull-request-available, ready-to-commit
> Fix For: 1.5
>
>   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.
>  
> Code already started with a pull request at 
> [https://github.com/zendawg/commons-cli] underneath the branch named 
> "cli-configuration".
> Apologies in advance, never contributed to Apache SWF before.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)