Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,31 @@ public void testNonEsa() throws Exception {
assertEquals("Incorrect resource count", 0, connectionList.getAllResources().size());
assertEquals("Incorrect feature count", 0, connectionList.getAllFeatures().size());
}

@Test
public void testOptionsBeforeAction() throws Exception {
RestRepositoryConnection repoConnection = (RestRepositoryConnection) repoServer.getAdminConnection();
RepositoryConnectionList connectionList = new RepositoryConnectionList(repoConnection);
String esaPath = "resources/com.ibm.websphere.appserver.adminCenter-1.0.esa";
File esaFile = new File(esaPath);

TestProcess tp = new TestProcess(Arrays.asList(FatUtils.SCRIPT,
"--url=" + FatUtils.SERVER_URL,
"upload",
"--username=" + repoConnection.getUserId(),
"--password=" + repoConnection.getPassword(),
esaPath));
tp.run();

tp.assertReturnCode(0);
assertEquals("Incorrect resource count", 1, connectionList.getAllResources().size());
assertEquals("Incorrect feature count", 1, connectionList.getAllFeatures().size());

EsaResourceWritable resource = (EsaResourceWritable) connectionList.getAllFeatures().iterator().next();
assertEquals("Incorrect state", State.PUBLISHED, resource.getState());
assertEquals("Incorrect license type", LicenseType.UNSPECIFIED, resource.getLicenseType());
assertEquals("Incorrect size", esaFile.length(), resource.getMainAttachmentSize());

tp.assertOutputContains("done");
}
}
16 changes: 15 additions & 1 deletion cli-client/src/main/java/com/ibm/ws/lars/upload/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,18 @@ private List<String> readActionAndOptions(String[] args) throws ClientException
throw new ClientException("No options were given", 1, HelpDisplay.SHOW_HELP);
}

// Allows options to be passed before actions. Considers the action that comes first.
String actionString = args[0];
int skipAction = 0;
for (int i = 0; i < args.length; i++) {
String tempActionString = args[i].startsWith("--") ? args[i].substring(2) : args[i];
if (Action.getByArgument(tempActionString) != null) {
skipAction = i;
actionString = args[i];
this.action = Action.getByArgument(args[i]);
break;
}
}

// If we're not invoked from a script, the action should start with "--"
if (getInvokedName() == null) {
Expand All @@ -198,7 +209,10 @@ private List<String> readActionAndOptions(String[] args) throws ClientException
this.options = new HashMap<Option, String>();

boolean keepProcessingOptions = true;
for (int i = 1; i < args.length; i++) {
for (int i = 0; i < args.length; i++) {
if (skipAction == i) {
continue;
}
String arg = args[i];

if (keepProcessingOptions && arg.equals("--")) {
Expand Down