Zond: проксирующий запускатор
This commit is contained in:
26
zond/build.gradle
Normal file
26
zond/build.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
group = 'asys'
|
||||
version = '0.1-SNAPSHOT'
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = "asys.zond.Main"
|
||||
|
||||
configurations {
|
||||
included
|
||||
compile.extendsFrom included
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': 'ASys Zond',
|
||||
'Implementation-Version': version,
|
||||
'Main-Class': mainClassName
|
||||
}
|
||||
baseName = project.group + '.' + project.name
|
||||
from { configurations.included.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
included group: 'org.fusesource.jansi', name: 'jansi', version: '1.11'
|
||||
included group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
|
||||
}
|
||||
54
zond/src/main/java/asys/zond/Main.java
Normal file
54
zond/src/main/java/asys/zond/Main.java
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user