UX tweaks, better output request behaviour

This commit is contained in:
Aidan Hahn 2019-05-23 23:29:41 -07:00
parent 88e745346e
commit 55b77789c3
No known key found for this signature in database
GPG key ID: 327711E983899316
7 changed files with 62 additions and 43 deletions

View file

@ -54,8 +54,8 @@ public class JobServClient {
try {
return Integer.parseInt(this.programArgs[index]);
} catch (InputMismatchException e) {
System.out.println(this.programArgs[index] + " is not a valid int, much less a valid pid");
} catch (NumberFormatException e) {
System.out.println(this.programArgs[index] + " is not a valid integer");
return -1;
}
@ -69,9 +69,9 @@ public class JobServClient {
System.out.println("... new (command)\n"+
"Starts a new process on the server\n"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 new echo hello world!\n\n"+
"... output (pid)\n"+
"Garners output from process on server\n"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 output 0\n\n"+
"... output (pid) (lines)\n"+
"Garners (lines) lines of output from process (pid) on server\n"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 output 0 5\n\n"+
"... status (pid)\n"+
"Returns whether process on server is running"+
"example: ./client key.pem cert.crt ca.crt localhost 8448 status 0\n\n"+
@ -88,11 +88,6 @@ public class JobServClient {
* makes a new process
*/
public void makeNewProcess() {
if (this.programArgs.length < 6) {
System.out.println("Improper formatting, try client --help");
return;
}
String command = "";
for (int token = 6; token < this.programArgs.length; token++) {
command += " " + this.programArgs[token];
@ -121,12 +116,18 @@ public class JobServClient {
* gets output from a process
*/
public void getOutput() {
if (this.programArgs.length < 8) {
System.out.println("Improper formatting, need a lines and a pid argument.");
return;
}
int candidatePid = this.getPidArg(6);
int lines = this.getPidArg(7);
if (candidatePid < 0) {
return;
}
String processOutput = this.api.getProcessOutput(candidatePid);
String processOutput = this.api.getProcessOutput(candidatePid, lines);
System.out.println(processOutput);
}