[jira] [Created] (NET-682) MVSFTPEntryParser doesn't support Record Formats of U
richard created NET-682: --- Summary: MVSFTPEntryParser doesn't support Record Formats of U Key: NET-682 URL: https://issues.apache.org/jira/browse/NET-682 Project: Commons Net Issue Type: Improvement Components: FTP Affects Versions: 3.6 Reporter: richard MVSFTPEntryParser doesn't support Record Formats of U and returns `null` for them. Example FTP output: Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname VV 3390 2020/04/18 1 60 U 32760 32760 PO NAME This is a ftp on the zOS which is reporting a MVS FTP and the list of record formats can be found at [https://www.ibm.com/support/knowledgecenter/zosbasics/com.ibm.zos.zconcepts/zconcepts_159.htm] . -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CLI-298) Define CLI options via configuration file
[ 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] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16954502#comment-16954502 ] Richard edited comment on CLI-298 at 10/18/19 11:07 AM: 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 -p 40 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...) was (Author: zendawg): 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
[jira] [Commented] (CLI-298) Define CLI options via configuration file
[ 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
[ 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
[ 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
[ 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
[ 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-237) CLIMessageBundle for Portuguese (attached)
[ https://issues.apache.org/jira/browse/CLI-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953668#comment-16953668 ] Richard commented on CLI-237: - I'm interested in this since I need to add I18N to my changes for CLI-298: As it stands, if users define their descriptions in another language, any errors will be printed in English and won't make sense to anyone that doesn't understand English. Tambem falo portuguese poquinho (Translation: I also speak a little bit of Portuguese) > CLIMessageBundle for Portuguese (attached) > -- > > Key: CLI-237 > URL: https://issues.apache.org/jira/browse/CLI-237 > Project: Commons CLI > Issue Type: Improvement > Components: CLI-2.x >Affects Versions: 2.0, Nightly Builds >Reporter: Ricardo Espirito Santo >Priority: Minor > Labels: i18n > Fix For: 2.1 > > Attachments: CLIMessageBundle_pt_PT.properties > > > A Portuguese (Portugal) message bundle -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CLI-298) Define CLI options via configuration file
[ 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
[ 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] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 10:07 PM: 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=MyOptionListener.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Main.java|borderStyle=solid} 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); } {code} was (Author: zendawg): 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:18 PM: --- 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=MyOptionListener.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Main.java|borderStyle=solid} MyAppListener listener = new MyAppListener(); 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); } {code} was (Author: zendawg): 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:16 PM: --- 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=MyOptionListener.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Main.java|borderStyle=solid} MyAppListener listener = new MyAppListener(); 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, 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); } {code} was (Author: zendawg): 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false option.writeover.description=If set,
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:15 PM: --- 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=MyOptionListener.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Main.java|borderStyle=solid} MyAppListener listener = new MyAppListener(); 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, 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); } {code} was (Author: zendawg): 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false option.writeover.description=If set, write over the
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953192#comment-16953192 ] Richard edited comment on CLI-298 at 10/16/19 9:14 PM: --- OK, sorted - I'd be happier with pure markdown editing but RTFM'd and it's all sorted now. was (Author: zendawg): 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] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:13 PM: --- 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: {code:title=opt.config|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=MyOptionListener.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Main.java|borderStyle=solid} MyAppListener listener = new MyAppListener(); 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, 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); } {code} was (Author: zendawg): 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: {code:title=Bar.java|borderStyle=solid} 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.hasArg=false option.writeover.description=If set, write over the
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:12 PM: --- 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: {code:title=Bar.java|borderStyle=solid} 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.hasArg=false 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. {code} Step 2: Create an option listener: {code:title=Bar.java|borderStyle=solid} 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)) { 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; } } } {code} 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: {code:title=Bar.java|borderStyle=solid} MyAppListener listener = new MyAppListener(); 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, 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); } {code} was (Author: zendawg): 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.hasArg=false option.writeover.description=If set, write over the existing file; \ otherwise, append to the file.
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:11 PM: --- 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.hasArg=false 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)) { 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: ``` MyAppListener listener = new MyAppListener(); 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, 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); } ``` was (Author: zendawg): 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.hasArg=false 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. ```
[jira] [Comment Edited] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953190#comment-16953190 ] Richard edited comment on CLI-298 at 10/16/19 9:02 PM: --- 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.hasArg=false 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 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)) { 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: ``` MyAppListener listener = new MyAppListener(); 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, 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); } ``` was (Author: zendawg): 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
[jira] [Commented] (CLI-298) Define CLI options via configuration file
[ 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
[ 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Description: 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. was: 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. 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. > 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: 2.0, Nightly Builds >Reporter: Richard >Priority: Trivial > Labels: newbie, pull-request-available, ready-to-commit > Fix For: 2.1 > > 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Affects Version/s: (was: 1.5) Nightly Builds > 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: 2.0, Nightly Builds >Reporter: Richard >Priority: Trivial > Labels: newbie, pull-request-available, ready-to-commit > Fix For: 1.5, 2.1 > > 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. > > 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Fix Version/s: (was: 1.5) > 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: 2.0, Nightly Builds >Reporter: Richard >Priority: Trivial > Labels: newbie, pull-request-available, ready-to-commit > Fix For: 2.1 > > 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. > > 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Fix Version/s: 2.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: CLI-2.x >Affects Versions: 1.5, 2.0 >Reporter: Richard >Priority: Trivial > Labels: newbie, pull-request-available, ready-to-commit > Fix For: 1.5, 2.1 > > 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. > > 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Affects Version/s: 2.0 > 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, 2.0 >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. Also add I18N > since this will be driven via the user experience for exception messages. > > 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] [Updated] (CLI-298) Define CLI options via configuration file
[ https://issues.apache.org/jira/browse/CLI-298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated CLI-298: Description: 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. 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. was: 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. > 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. Also add I18N > since this will be driven via the user experience for exception messages. > > 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
[ 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)
[jira] [Created] (CLI-298) Define CLI options via configuration file
Richard created CLI-298: --- Summary: 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 Fix For: 1.5 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)
[jira] [Commented] (FILEUPLOAD-197) ServletFileUpload isMultipartContent method does not support HTTP PUT
[ https://issues.apache.org/jira/browse/FILEUPLOAD-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13542838#comment-13542838 ] Richard commented on FILEUPLOAD-197: I have also encountered this problem. Whilst the spec may not specifically apply to PUT I believe that in a practical sense it would be expected that this api could use PUT to replace resources that were created via POST. How else then should they be replaced? The crux of the issue of that it's not really possible to get the correct content type or content length of the resource being put, as if it's not a multi part request then those attributes are those of the request, not of the resource. To support this, multipart request has to be allowed for PUT. ServletFileUpload isMultipartContent method does not support HTTP PUT - Key: FILEUPLOAD-197 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-197 Project: Commons FileUpload Issue Type: Bug Affects Versions: 1.2.1 Reporter: David Wolverton This method explicitly checks for method POST. I believe the PUT method can also have multipart requests, and there may be others. In our case we are receiving rest calls using Spring Framework's CommonsMultipartResolver which in turn uses this method of the Commons FileUpload library. Here is the offending code... if (!post.equals(request.getMethod().toLowerCase())) { return false; } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Deleted] (FILEUPLOAD-197) ServletFileUpload isMultipartContent method does not support HTTP PUT
[ https://issues.apache.org/jira/browse/FILEUPLOAD-197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Richard updated FILEUPLOAD-197: --- Comment: was deleted (was: I have also encountered this problem. Whilst the spec may not specifically apply to PUT I believe that in a practical sense it would be expected that this api could use PUT to replace resources that were created via POST. How else then should they be replaced? The crux of the issue of that it's not really possible to get the correct content type or content length of the resource being put, as if it's not a multi part request then those attributes are those of the request, not of the resource. To support this, multipart request has to be allowed for PUT.) ServletFileUpload isMultipartContent method does not support HTTP PUT - Key: FILEUPLOAD-197 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-197 Project: Commons FileUpload Issue Type: Bug Affects Versions: 1.2.1 Reporter: David Wolverton This method explicitly checks for method POST. I believe the PUT method can also have multipart requests, and there may be others. In our case we are receiving rest calls using Spring Framework's CommonsMultipartResolver which in turn uses this method of the Commons FileUpload library. Here is the offending code... if (!post.equals(request.getMethod().toLowerCase())) { return false; } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira