dev.jbang.cli.DependencyInfoMixin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbang-cli Show documentation
Show all versions of jbang-cli Show documentation
JBang Command Line Interface
package dev.jbang.cli;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import picocli.CommandLine;
public class DependencyInfoMixin {
@CommandLine.Option(names = { "-D" }, description = "set a system property", mapFallbackValue = "true")
Map properties;
@CommandLine.Option(names = {
"--deps" }, converter = CommaSeparatedConverter.class, description = "Add additional dependencies (Use commas to separate them).")
List dependencies;
@CommandLine.Option(names = {
"--repos" }, converter = CommaSeparatedConverter.class, description = "Add additional repositories.")
List repositories;
@CommandLine.Option(names = { "--cp", "--class-path" }, description = "Add class path entries.")
List classpaths;
public List getDependencies() {
return dependencies;
}
public List getRepositories() {
return repositories;
}
public List getClasspaths() {
return classpaths;
}
public Map getProperties() {
return properties;
}
public List opts() {
List opts = new ArrayList<>();
if (properties != null) {
for (Map.Entry e : properties.entrySet()) {
opts.add("-D");
opts.add(e.getKey() + "=" + e.getValue());
}
}
if (dependencies != null) {
for (String d : dependencies) {
opts.add("--deps");
opts.add(d);
}
}
if (repositories != null) {
for (String r : repositories) {
opts.add("--repos");
opts.add(r);
}
}
if (classpaths != null) {
for (String c : classpaths) {
opts.add("--cp");
opts.add(c);
}
}
return opts;
}
}