-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
Add -version and -help #349
Conversation
|
||
public static void main(String... args) throws Exception { | ||
Launcher launcher = new Launcher(); | ||
CmdLineParser parser = new CmdLineParser(launcher); | ||
try { | ||
parser.parseArgument(args); | ||
if (launcher.showHelp && !launcher.showVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we specify version and help it shows the version. Should this be the behaviour? Just thinking out loud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include the version in the help output? I recall seeing some tools behave like that, but at the moment I'm not finding any examples.
At a minimum, maybe help should take precedence over version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was modeling this behavior after what jenkins.war does. If you run java -jar jenkins.war --help --version
it prints the version. We can definitely switch the priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with being consistent with jenkins.war.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How have you tested the version result? When I test it I just get
agent.jar version null
Maybe we ought to add similar options to the Main
entry point. The problem is that we have two entry points and maybe we shouldn't propagate that, but maybe it would be good to add to both for consistency. Just thinking aloud here also.
|
||
public static void main(String... args) throws Exception { | ||
Launcher launcher = new Launcher(); | ||
CmdLineParser parser = new CmdLineParser(launcher); | ||
try { | ||
parser.parseArgument(args); | ||
if (launcher.showHelp && !launcher.showVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include the version in the help output? I recall seeing some tools behave like that, but at the moment I'm not finding any examples.
At a minimum, maybe help should take precedence over version.
"You can obtain usage information by executing |
When I try these, they work by side-effect rather than by design. They show the usage text because the parameters are wrong, not because "--help" is a valid parameter. I think it could be a minor improvement to implement "--help" so that it shows usage without showing "two arguments required, but got []" or '"--help" is not a valid option'. And I think having a version option could be useful but I'm not sure it's working correctly yet. |
@slide, do you want to complete this PR? |
For reason I didn't get any notification of the comments on this PR. I will review them and update as necessary. |
@slide, except for the introduction of a spotbugs error this looks good. If you could get that taken care of, I'd like to include this and several other chore PRs in a release right away. "Exception is caught when Exception is not thrown in hudson.remoting.Util.getVersion() [hudson.remoting.Util] At Util.java:[line 181] REC_CATCH_EXCEPTION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can get a clean CI build, I'll see if I can release this and a few other chores tomorrow. Unless there are objections.
Thanks for adding these parameters. |
Adds -version and a -help command line options.