Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit a28a614

Browse files
committed
#253 Added command to CLI to print properties
1 parent 3850f0e commit a28a614

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

src/main/java/com/marklogic/appdeployer/cli/Main.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
import java.io.FileInputStream;
2222
import java.io.IOException;
23-
import java.util.List;
24-
import java.util.Map;
25-
import java.util.Properties;
26-
import java.util.TreeMap;
23+
import java.util.*;
2724

2825
public class Main {
2926

@@ -46,7 +43,11 @@ public static void main(String[] args) throws IOException {
4643

4744
String parsedCommand = commander.getParsedCommand();
4845
if (parsedCommand == null) {
49-
commander.usage();
46+
if (options.isPrintProperties()) {
47+
printProperties();
48+
} else {
49+
commander.usage();
50+
}
5051
} else {
5152
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
5253
root.setLevel(Level.toLevel(options.getLogLevel()));
@@ -121,6 +122,23 @@ private static PropertySource buildPropertySource(Options options) throws IOExce
121122
}
122123
}
123124

125+
private static void printProperties() {
126+
System.out.println("\nManage server connection properties");
127+
for (String name : new TreeSet<>(new DefaultManageConfigFactory().getPropertyConsumerMap().keySet())) {
128+
System.out.println(" - " + name);
129+
}
130+
131+
System.out.println("\nAdmin server connection properties");
132+
for (String name : new TreeSet<>(new DefaultAdminConfigFactory().getPropertyConsumerMap().keySet())) {
133+
System.out.println(" - " + name);
134+
}
135+
136+
System.out.println("\nApplication properties");
137+
for (String name : new TreeSet<>(new DefaultAppConfigFactory().getPropertyConsumerMap().keySet())) {
138+
System.out.println(" - " + name);
139+
}
140+
}
141+
124142
/**
125143
* @param commandArray
126144
* @param propertySource

src/main/java/com/marklogic/appdeployer/cli/Options.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ public class Options {
1212
@Parameter(names = {"-f"}, description = "Path to properties file")
1313
private String propertiesFilePath;
1414

15-
@Parameter(names = {"-u"}, description = "Undo the given command (i.e. undeploy instead of deploy)")
16-
private boolean undo;
17-
1815
@Parameter(names = {"-l"}, description = "Log level, as defined by Logback")
1916
private String logLevel = Level.INFO.levelStr;
2017

18+
@Parameter(names = {"-p"}, description = "Print a list of all supported properties")
19+
private boolean printProperties;
20+
21+
@Parameter(names = {"-u"}, description = "Undo the given command (i.e. undeploy instead of deploy)")
22+
private boolean undo;
23+
2124
@DynamicParameter(names = "-P", description = "Use this argument to include any property defined by the ml-gradle Property Reference; e.g. -PmlAppName=example")
2225
private Map<String, String> params = new HashMap<>();
2326

@@ -52,5 +55,13 @@ public String getLogLevel() {
5255
public void setLogLevel(String logLevel) {
5356
this.logLevel = logLevel;
5457
}
58+
59+
public boolean isPrintProperties() {
60+
return printProperties;
61+
}
62+
63+
public void setPrintProperties(boolean printProperties) {
64+
this.printProperties = printProperties;
65+
}
5566
}
5667

0 commit comments

Comments
 (0)