Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation in SampleMain.java #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix deprecation in SampleMain.java #147

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 26, 2017

@sfuhrm , this is the updated version of my previous pull request. I had to create a new one because I deleted the repository I used.

I removed CmdLineException and matched the formatting of argument.isEmpty() to the other if statements.

Displays usage of all of the methods showed in the previous sample.
Copy link

@sfuhrm sfuhrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for re-pull-requesting, @KarlFish
Looks already quite good.
I have two small suggestions for you.

return;
}

if( arguments.isEmpty() )
System.out.println("No args given. Example useage: java SampleMain" + parser.printExample(OptionHandlerFilter.ALL));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go to System.err, as goes e.printStackTrace()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the help message on parsing error was a mistake, thanks for correcting that.

The second change depends on whether the program should run given no arguments. However, programs that use args4j will likely require some arguments to run correctly. I agree with this change as well.

System.err.println(" Example: java SampleMain"+parser.printExample(ALL));

} catch (CmdLineException e) {
e.printStackTrace();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The printing of the help message in case of a CmdLineException (malformed CLI options) is completely lost which was a good example in my humble opinion:

           System.err.println(e.getMessage());
            System.err.println("java SampleMain [options...] arguments...");
            // print the list of available options
            parser.printUsage(System.err);
            System.err.println();

@ghost
Copy link
Author

ghost commented Jan 28, 2017

Removing the help message on parsing error was a mistake, thanks for correcting that.

The second change depends on whether the program should run given no arguments. However, programs that use args4j will likely require some arguments to run correctly. I agree with this change as well.

@sfuhrm
Copy link

sfuhrm commented Jan 29, 2017

Thanks for fixing the deprecations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants