Skip to content

Commit

Permalink
[FIXED JENKINS-38650] - Cleanup spelling in CLi commands + Javadoc up…
Browse files Browse the repository at this point in the history
…dates (#2571)

* [FIXED JENKINS-38650] - Cleanup spelling in CLi commands.

Also adds some javadoc and since definitions.

* [JENKINS-38650] - Move common warning message to the constant

* [JENKINS-38650] - DeleteViewCommand should also use the constant string

* [JENKINS-38650] - Rename the constant in order to make the name more explicit
  • Loading branch information
oleg-nenashev committed Oct 15, 2016
1 parent b62ad15 commit b50034c
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 53 deletions.
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/cli/CLICommand.java
Expand Up @@ -124,6 +124,13 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
*/
public transient PrintStream stdout,stderr;

/**
* Shared text, which is reported back to CLI if an error happens in commands
* taking lists of parameters.
* @since TODO
*/
static final String CLI_LISTPARAM_SUMMARY_ERROR_TEXT = "Error occurred while performing this command, see previous stderr output.";

/**
* Connected to stdin of the CLI agent.
*
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/CancelQuietDownCommand.java
Expand Up @@ -33,7 +33,7 @@
* Cancel previous quiet down Jenkins - preparation for a restart
*
* @author pjanouse
* @since TODO
* @since 2.14
*/
@Extension
public class CancelQuietDownCommand extends CLICommand {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/ClearQueueCommand.java
Expand Up @@ -34,7 +34,7 @@
* Clears the build queue
*
* @author pjanouse
* @since TODO
* @since 1.654
*/
@Extension
public class ClearQueueCommand extends CLICommand {
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/hudson/cli/ConnectNodeCommand.java
Expand Up @@ -37,13 +37,14 @@
import java.util.logging.Logger;

/**
* Reconnect to a node or nodes.
* @author pjanouse
* @since TODO
* @since 2.6
*/
@Extension
public class ConnectNodeCommand extends CLICommand {

@Argument(metaVar="NAME", usage="Slave name, or empty string for master; comama-separated list is supported", required=true, multiValued=true)
@Argument(metaVar="NAME", usage="Slave name, or empty string for master; comma-separated list is supported", required=true, multiValued=true)
private List<String> nodes;

@Option(name="-f", usage="Cancel any currently pending connect operation and retry from scratch")
Expand Down Expand Up @@ -96,7 +97,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/cli/DeleteJobCommand.java
Expand Up @@ -34,8 +34,9 @@
import java.util.logging.Logger;

/**
* CLI command, which deletes a job or multiple jobs.
* @author pjanouse
* @since TODO
* @since 1.649
*/
@Extension
public class DeleteJobCommand extends CLICommand {
Expand Down Expand Up @@ -83,7 +84,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/hudson/cli/DeleteNodeCommand.java
Expand Up @@ -34,13 +34,14 @@
import java.util.logging.Logger;

/**
* CLI command, which deletes Jenkins nodes.
* @author pjanouse
* @since TODO
* @since 1.618
*/
@Extension
public class DeleteNodeCommand extends CLICommand {

@Argument(usage="Nodes name to delete", required=true, multiValued=true)
@Argument(usage="Names of nodes to delete", required=true, multiValued=true)
private List<String> nodes;

@Override
Expand Down Expand Up @@ -82,7 +83,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/DeleteViewCommand.java
Expand Up @@ -95,7 +95,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/hudson/cli/DisconnectNodeCommand.java
Expand Up @@ -37,12 +37,13 @@
import java.util.logging.Logger;

/**
* CLI Command, which disconnects nodes.
* @author pjanouse
* @since TODO
* @since 2.14
*/
@Extension
public class DisconnectNodeCommand extends CLICommand {
@Argument(metaVar = "NAME", usage = "Slave name, or empty string for master; comama-separated list is supported", required = true, multiValued = true)
@Argument(metaVar = "NAME", usage = "Slave name, or empty string for master; comma-separated list is supported", required = true, multiValued = true)
private List<String> nodes;

@Option(name = "-m", usage = "Record the reason about why you are disconnecting this node")
Expand Down Expand Up @@ -94,7 +95,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/cli/OfflineNodeCommand.java
Expand Up @@ -39,8 +39,9 @@
import java.util.List;

/**
* CLI Command, which puts the Jenkins node offline.
* @author pjanouse
* @since TODO
* @since 2.15
*/
@Extension
public class OfflineNodeCommand extends CLICommand {
Expand Down Expand Up @@ -88,7 +89,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/cli/OnlineNodeCommand.java
Expand Up @@ -37,8 +37,9 @@
import java.util.List;

/**
* CLI Command, which moves the node to the online state.
* @author pjanouse
* @since TODO
* @since 1.642
*/
@Extension
public class OnlineNodeCommand extends CLICommand {
Expand Down Expand Up @@ -86,7 +87,7 @@ protected int run() throws Exception {
}

if (errorOccurred){
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/cli/QuietDownCommand.java
Expand Up @@ -34,7 +34,7 @@
* Quiet down Jenkins - preparation for a restart
*
* @author pjanouse
* @since TODO
* @since 2.14
*/
@Extension
public class QuietDownCommand extends CLICommand {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/cli/ReloadConfigurationCommand.java
Expand Up @@ -28,10 +28,10 @@
import jenkins.model.Jenkins;

/**
* Reload everything from file system
* Reload everything from the file system.
*
* @author pjanouse
* @since TODO
* @since 2.4
*/
@Extension
public class ReloadConfigurationCommand extends CLICommand {
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/cli/ReloadJobCommand.java
Expand Up @@ -38,8 +38,9 @@
import java.util.logging.Logger;

/**
* Reloads job from the disk.
* @author pjanouse
* @since TODO
* @since 1.633
*/
@Extension
public class ReloadJobCommand extends CLICommand {
Expand Down Expand Up @@ -100,7 +101,7 @@ protected int run() throws Exception {
}

if (errorOccurred) {
throw new AbortException("Error occured while performing this command, see previous stderr output.");
throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
}
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/cli/WaitNodeOfflineCommand.java
Expand Up @@ -28,8 +28,9 @@
import org.kohsuke.args4j.Argument;

/**
* CLI command, which waits till the node switches to the offline state.
* @author pjanouse
* @since TODO
* @since 2.16
*/
@Extension
public class WaitNodeOfflineCommand extends CLICommand {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/cli/WaitNodeOnlineCommand.java
Expand Up @@ -28,8 +28,9 @@
import org.kohsuke.args4j.Argument;

/**
* CLI command, which waits till the node switches to the online state.
* @author pjanouse
* @since TODO
* @since 2.16
*/
@Extension
public class WaitNodeOnlineCommand extends CLICommand {
Expand Down
6 changes: 3 additions & 3 deletions test/src/test/java/hudson/cli/ConnectNodeCommandTest.java
Expand Up @@ -64,7 +64,7 @@ public class ConnectNodeCommandTest {
assertThat(result, failedWith(6));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("ERROR: user is missing the Agent/Connect permission"));
assertThat(result.stderr(), not(containsString("ERROR: Error occured while performing this command, see previous stderr output.")));
assertThat(result.stderr(), not(containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT)));
}

@Test public void connectNodeShouldFailIfNodeDoesNotExist() throws Exception {
Expand All @@ -74,7 +74,7 @@ public class ConnectNodeCommandTest {
assertThat(result, failedWith(3));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("ERROR: No such agent \"never_created\" exists."));
assertThat(result.stderr(), not(containsString("ERROR: Error occured while performing this command, see previous stderr output.")));
assertThat(result.stderr(), not(containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT)));
}

@Test public void connectNodeShouldSucceed() throws Exception {
Expand Down Expand Up @@ -156,7 +156,7 @@ public class ConnectNodeCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such agent \"never_created\" exists. Did you mean \"aNode1\"?"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));
assertThat(slave1.toComputer().isOnline(), equalTo(true));
assertThat(slave2.toComputer().isOnline(), equalTo(true));
}
Expand Down
8 changes: 4 additions & 4 deletions test/src/test/java/hudson/cli/DeleteJobCommandTest.java
Expand Up @@ -131,7 +131,7 @@ public class DeleteJobCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such job 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getItem("aProject1"), nullValue());
assertThat(j.jenkins.getItem("aProject2"), nullValue());
Expand All @@ -150,7 +150,7 @@ public class DeleteJobCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such job 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getItem("aProject1"), nullValue());
assertThat(j.jenkins.getItem("aProject2"), nullValue());
Expand All @@ -169,7 +169,7 @@ public class DeleteJobCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such job 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getItem("aProject1"), nullValue());
assertThat(j.jenkins.getItem("aProject2"), nullValue());
Expand All @@ -189,7 +189,7 @@ public class DeleteJobCommandTest {
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created1: No such job 'never_created1'"));
assertThat(result.stderr(), containsString("never_created2: No such job 'never_created2'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getItem("aProject1"), nullValue());
assertThat(j.jenkins.getItem("aProject2"), nullValue());
Expand Down
8 changes: 4 additions & 4 deletions test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
Expand Up @@ -118,7 +118,7 @@ public class DeleteNodeCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such node 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aNode1"), nullValue());
assertThat(j.jenkins.getView("aNode2"), nullValue());
Expand All @@ -137,7 +137,7 @@ public class DeleteNodeCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such node 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aNode1"), nullValue());
assertThat(j.jenkins.getView("aNode2"), nullValue());
Expand All @@ -156,7 +156,7 @@ public class DeleteNodeCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No such node 'never_created'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aNode1"), nullValue());
assertThat(j.jenkins.getView("aNode2"), nullValue());
Expand All @@ -176,7 +176,7 @@ public class DeleteNodeCommandTest {
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created1: No such node 'never_created1'"));
assertThat(result.stderr(), containsString("never_created2: No such node 'never_created2'"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aNode1"), nullValue());
assertThat(j.jenkins.getView("aNode2"), nullValue());
Expand Down
10 changes: 5 additions & 5 deletions test/src/test/java/hudson/cli/DeleteViewCommandTest.java
Expand Up @@ -175,7 +175,7 @@ public class DeleteViewCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No view named never_created inside view Jenkins"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aView1"), nullValue());
assertThat(j.jenkins.getView("aView2"), nullValue());
Expand All @@ -194,7 +194,7 @@ public class DeleteViewCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No view named never_created inside view Jenkins"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aView1"), nullValue());
assertThat(j.jenkins.getView("aView2"), nullValue());
Expand All @@ -213,7 +213,7 @@ public class DeleteViewCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created: No view named never_created inside view Jenkins"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aView1"), nullValue());
assertThat(j.jenkins.getView("aView2"), nullValue());
Expand All @@ -233,7 +233,7 @@ public class DeleteViewCommandTest {
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("never_created1: No view named never_created1 inside view Jenkins"));
assertThat(result.stderr(), containsString("never_created2: No view named never_created2 inside view Jenkins"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aView1"), nullValue());
assertThat(j.jenkins.getView("aView2"), nullValue());
Expand Down Expand Up @@ -267,7 +267,7 @@ public class DeleteViewCommandTest {
assertThat(result, failedWith(5));
assertThat(result, hasNoStandardOutput());
assertThat(result.stderr(), containsString("All: Jenkins does not allow to delete 'All' view"));
assertThat(result.stderr(), containsString("ERROR: Error occured while performing this command, see previous stderr output."));
assertThat(result.stderr(), containsString("ERROR: " + CLICommand.CLI_LISTPARAM_SUMMARY_ERROR_TEXT));

assertThat(j.jenkins.getView("aView1"), nullValue());
assertThat(j.jenkins.getView("aView2"), nullValue());
Expand Down

0 comments on commit b50034c

Please sign in to comment.