-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathDebuggerOptions.java
More file actions
115 lines (93 loc) · 3.91 KB
/
Copy pathDebuggerOptions.java
File metadata and controls
115 lines (93 loc) · 3.91 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
/*
* This file is a part of Coverage41C.
*
* Copyright (c) 2020-2022
* Kosolapov Stanislav aka proDOOMman <prodoomman@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Coverage41C is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* Coverage41C is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Coverage41C.
*/
package com.clouds42.CommandLineOptions;
import com.clouds42.DebugTargetType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine.Option;
import java.lang.invoke.MethodHandles;
import java.lang.module.ModuleDescriptor;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class DebuggerOptions {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@Option(names = {"-p", "--password"}, description = "Dbgs password", interactive = true, defaultValue = "")
private String password;
@Option(names = {"-p:env", "--password:env"}, description = "Password environment variable name", defaultValue = "")
private String passwordEnv;
@Option(names = {"-n", "--areanames"}, description = "Debug area names (not for general use!)", arity = "0..*")
private List<String> debugAreaNames;
@Option(names = {"-a", "--autoconnectTargets"}, description = "Autoconnect debug targets (not for general use!): ${COMPLETION-CANDIDATES}", arity = "0..*")
private List<DebugTargetType> autoconnectTargets;
@Option(names = {"-t", "--timeout"}, description = "Ping timeout. Default - ${DEFAULT-VALUE}", defaultValue = "1000")
private Integer pingTimeout;
public String getPassword() {
if (password != null) {
if (password.trim().isEmpty()) {
if (!passwordEnv.isEmpty()) {
password = System.getenv(passwordEnv);
passwordEnv = "";
}
}
}
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<String> getDebugAreaNames() {
if (debugAreaNames == null) {
return new ArrayList<>();
} else {
return debugAreaNames;
}
}
public void setDebugAreaNames(List<String> debugAreaNames) {
this.debugAreaNames = debugAreaNames;
}
public Integer getPingTimeout() {
return pingTimeout;
}
public void setPingTimeout(Integer pingTimeout) {
this.pingTimeout = pingTimeout;
}
public void setAutoconnectTargets(List<DebugTargetType> autoconnectTargets) {
this.autoconnectTargets = autoconnectTargets;
}
public List<DebugTargetType> getAutoconnectTargets() {
if (autoconnectTargets == null || autoconnectTargets.isEmpty()) {
autoconnectTargets = new LinkedList<DebugTargetType>();
autoconnectTargets.addAll(DebugTargetType.VALUES);
autoconnectTargets.remove(DebugTargetType.UNKNOWN);
}
return autoconnectTargets;
}
public List<DebugTargetType> getFilteredAutoconnectTargets(ModuleDescriptor.Version ApiVersion) {
List<DebugTargetType> debugTypes = getAutoconnectTargets();
if (ModuleDescriptor.Version.parse("8.3.16").compareTo(ApiVersion) > 0) {
debugTypes.remove(DebugTargetType.MOBILE_MANAGED_CLIENT);
logger.info("[{}] was removed", DebugTargetType.MOBILE_MANAGED_CLIENT);
}
return debugTypes;
}
}