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

Add -version and -help #349

Merged
merged 3 commits into from
Nov 2, 2019
Merged

Add -version and -help #349

merged 3 commits into from
Nov 2, 2019

Conversation

slide
Copy link
Member

@slide slide commented Sep 24, 2019

Adds -version and a -help command line options.

@jeffret-b jeffret-b self-requested a review September 24, 2019 22:06

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) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@jeffret-b jeffret-b left a 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) {
Copy link
Contributor

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.

@oleg-nenashev
Copy link
Member

"You can obtain usage information by executing java -cp agent.jar hudson.remoting.jnlp.Main or java -jar agent.jar --help. " in documentation. I was sure help was implemented at some point. There are 2 launch classes tho

@jeffret-b
Copy link
Contributor

"You can obtain usage information by executing java -cp agent.jar hudson.remoting.jnlp.Main or java -jar agent.jar --help. " in documentation. I was sure help was implemented at some point. There are 2 launch classes tho

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.

@jeffret-b
Copy link
Contributor

@slide, do you want to complete this PR?

@slide
Copy link
Member Author

slide commented Oct 29, 2019

For reason I didn't get any notification of the comments on this PR. I will review them and update as necessary.

@jeffret-b
Copy link
Contributor

@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"

Copy link
Contributor

@jeffret-b jeffret-b left a 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.

@jeffret-b jeffret-b added ready-to-merge enhancement For changelog: An enhancement providing new capability. labels Nov 2, 2019
@jeffret-b jeffret-b merged commit d1c8a4c into jenkinsci:master Nov 2, 2019
@jeffret-b
Copy link
Contributor

Thanks for adding these parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For changelog: An enhancement providing new capability. ready-to-merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants