Archived
0

Zond: проксирующий запускатор

This commit is contained in:
2017-06-08 00:44:01 +03:00
parent 43f3bdc8e9
commit 400e821b0e
4 changed files with 82 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2017-06-07
* Idea by Daniil on 2017-06-07
*/
package asys.zond;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.PumpStreamHandler;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Color;
import org.fusesource.jansi.AnsiConsole;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;
import static org.fusesource.jansi.Ansi.ansi;
public class Main {
public static void main(String[] args) throws IOException {
if (Boolean.getBoolean("ansi.install")) {
AnsiConsole.systemInstall();
}
Ansi ansi = ansi().reset();
ansi.bold().fg(Color.WHITE).a("ASys").boldOff().a(":// ");
ansi.fg(Color.BLACK).bg(Color.RED).a("Zond").reset().newline();
System.out.println(ansi.toString());
if (args.length == 0) {
System.out.println("no args");
System.exit(0);
return;
}
String cmdLine = Arrays.stream(args).collect(Collectors.joining(" "));
CommandLine commandLine = CommandLine.parse(cmdLine);
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.setStreamHandler(new PumpStreamHandler(System.out, System.err, System.in));
int resultCode = 0;
try {
resultCode = executor.execute(commandLine);
} catch (ExecuteException ignore) {
}
System.out.print(ansi().reset().newline()
.fg(Color.GREEN).a("Process Finished. Code: ")
.bold().fg(Color.WHITE).a(resultCode).reset().newline());
}
}