-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrunQDup.java
executable file
·76 lines (61 loc) · 2.41 KB
/
runQDup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.hyperfoil.tools:qDup:0.6.12
//DEPS org.apache.commons:commons-lang3:3.12.0
import org.apache.commons.lang3.ArrayUtils;
import io.hyperfoil.tools.qdup.QDup;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Files;
import java.net.InetAddress;
import java.io.IOException;
class runQDup {
public static void main(String... args) throws Exception {
String pwd = "", username = "", hostname = "";
Path tempDirWithPrefix = null;
try{
pwd = System.getProperty("user.dir");
username = System.getProperty("user.name");
hostname = InetAddress.getLocalHost().getHostName();
tempDirWithPrefix = Files.createTempDirectory("qDup");
} catch (NullPointerException|IllegalArgumentException|UnsupportedOperationException|IOException|SecurityException exception){
System.err.println("Could not determine system properties");
System.exit(1);
}
String projectPath = "";
for(File file = new File(pwd); file != null; file = file.getParentFile()){
if( file.getName().equals("qDup")){
projectPath = file.toPath().toString();
break;
}
}
if(projectPath.equals("")) {
System.err.println("Could not determine project directory");
System.exit(1);
}
String qDupFilePath = null;
try{
qDupFilePath = System.getProperty("qDupScript");
if(qDupFilePath.substring(0,1).equals(".")){
qDupFilePath = pwd + qDupFilePath.substring(1,qDupFilePath.length());
}
File qDupFile = new File(qDupFilePath);
if(!qDupFile.exists()){
System.err.printf("File not found: %s\n", qDupFilePath);
System.exit(1);
} else {
qDupFilePath = qDupFile.getPath();
}
} catch(SecurityException|NullPointerException|IllegalArgumentException exception){
}
String[] qDupBaseArgs = {
qDupFilePath != null ? qDupFilePath : projectPath + "/docs/examples/helloWorld.yaml"
, "-S"
, "USER=" + username
, "-S"
, "HOST=" + hostname
};
String[] qDupArgs = ArrayUtils.addAll(qDupBaseArgs, args);
QDup qDup = new QDup(qDupArgs);
qDup.run();
}
}