-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArgs.java
More file actions
117 lines (86 loc) · 5.1 KB
/
Copy pathArgs.java
File metadata and controls
117 lines (86 loc) · 5.1 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package lt.lb.mavencopydeploy;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
import java.io.File;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import lt.lb.commons.Java;
import lt.lb.commons.containers.collections.ImmutableCollections;
import lt.lb.commons.iteration.streams.MakeStream;
import org.apache.commons.lang3.StringUtils;
/**
*
* @author laim0nas100
*/
public class Args {
public static enum Mode {
COMPARE, COPY, DOWNLOAD
}
@Parameter(names = "-mode", required = false, description = "COPY/COMPARE/DOWNLOAD", converter = ModeConverter.class)
public Mode mode = Mode.DOWNLOAD;
@Parameter(names = "-inclext", required = false, description = "included extensions, leave empty for disable")
public List<String> includedExt = ImmutableCollections.listOf();
@Parameter(names = "-exclext", required = false, description = "excluded extensions, leave empty for disable")
public List<String> excludedExt = ImmutableCollections.listOf("md5", "sha1");
@Parameter(names = "-vs", required = false, description = "Source Nexus version 2 or 3")
public int versionSource = 3;
@Parameter(names = "-vd", required = false, description = "Source Nexus version 2 or 3")
public int versionDest = 3;
@Parameter(names = "-su", required = true, description = "Source Nexus user")
public String userSrc;
@Parameter(names = "-sp", required = true, description = "Source Nexus password")
public String paswSrc;
@Parameter(names = "-du", required = false, description = "Destination Nexus user")
public String userDst;
@Parameter(names = "-dp", required = false, description = "Destination Nexus password")
public String paswDst;
@Parameter(names = "-srcdomain", required = true, description = "Nexus source repository domain.")
public String domainSrc;
@Parameter(names = "-destdomain", required = false, description = "Nexus destination repository domain.")
public String domainDest;
@Parameter(names = "-srcid", required = true, description = "ID (name) of a source repository")
public String idSrc;
@Parameter(names = "-destid", required = false, description = "ID (name) of a destination repository")
public String idDest;
@Parameter(names = "-temppath", required = false, description = "Folder to store artifacts temporarily. Will be created if absent and will not be deleted afterwards. Should be empty, or not contain any files with number for their names."
+ "In case of compare option, this path will be used to store compare.txt file with compare info.")
public String localPath = System.getProperty("user.home") + File.separator + "MavenCopyDeployWorkFolder";
@Parameter(names = "-maxtemp", required = false, description = "Maximum number of temporary files to store before deleting. Set to <= 0 in order to ignore.")
public int maxTemp = 500;
@Parameter(names = "-tc", required = false, description = "Number of threads to use. 0 means no threads (will run as a single threaded processs), below zero means unlimited")
public int threadCount = Java.getAvailableProcessors();
@Parameter(names = "-downloadpath", required = false, description = "download")
public String downloadPath = System.getProperty("user.home") + File.separator + "MavenCopyDeployWorkFolder" + File.separator + "download";
@Parameter(names = "-disablelog", required = false, description = "disable logging")
public boolean disableLog = false;
@Parameter(names = {"--help", "-help", "help", "?"}, help = true)
public boolean help;
@Override
public String toString() {
return "Args{" + "mode=" + mode + ", includedExt=" + includedExt + ", excludedExt=" + excludedExt + ", versionSource=" + versionSource + ", versionDest=" + versionDest + ", userSrc=" + userSrc + ", paswSrc=" + paswSrc + ", userDst=" + userDst + ", paswDst=" + paswDst + ", domainSrc=" + domainSrc + ", domainDest=" + domainDest + ", idSrc=" + idSrc + ", idDest=" + idDest + ", localPath=" + localPath + ", maxTemp=" + maxTemp + ", threadCount=" + threadCount + ", downloadPath=" + downloadPath + ", disableLog=" + disableLog + ", help=" + help + '}';
}
public static <T extends Enum<T>> List<String> enumNames(Class<T> cls) {
return MakeStream.from(EnumSet.allOf(cls))
.sorted(Comparator.comparing(m -> m.ordinal()))
.map(m -> m.name())
.toList();
}
public static <T extends Enum<T>> T enumFromString(Class<T> cls, String value) {
Objects.requireNonNull(value);
EnumSet<T> all = EnumSet.allOf(cls);
for (T e : all) {
if (StringUtils.equalsIgnoreCase(e.name(), value)) {
return e;
}
}
throw new IllegalArgumentException(value + " is not part of acceptable values:" + enumNames(cls));
}
public static class ModeConverter implements IStringConverter<Mode> {
@Override
public Mode convert(String value) {
return enumFromString(Mode.class, value);
}
}
}