io.microconfig.MicroconfigParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microconfig-cli Show documentation
Show all versions of microconfig-cli Show documentation
Powerful tool for microservice configuration management
package io.microconfig;
import lombok.RequiredArgsConstructor;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static io.microconfig.CommandLineParamParser.printErrorAndExit;
@RequiredArgsConstructor
public class MicroconfigParams {
private final CommandLineParamParser parser;
public static MicroconfigParams parse(String... args) {
return new MicroconfigParams(CommandLineParamParser.parse(args));
}
public File rootDir() {
return new File(parser.valueOr("r", "."));
}
public String destinationDir() {
return parser.valueOr("d", "build");
}
public List groups() {
return parser.listValue("g");
}
public List services() {
return parser.listValue("s");
}
public boolean stacktrace() {
return parser.booleanValue("stacktrace");
}
public boolean version() {
return parser.contains("v");
}
public boolean jsonOutput() {
return "json".equals(parser.value("output"));
}
public Set environments() {
Set environments = new LinkedHashSet<>(parser.listValue("envs"));
String env = parser.value("e");
if (env != null) {
if (env.equals("*")) {
printErrorAndExit("use -envs instead of -e to pass `*` as a value");
}
environments.add(env);
}
if (environments.isEmpty()) {
printErrorAndExit("set `-e (environment)` or `-envs (env1),(env2)...`");
}
return environments;
}
public boolean isSingleEnvBuild() {
return parser.contains("e") && !parser.contains("envs");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy