use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _profile.
@Description("Profile management. A profile is a JAR that only contains packages and capabilities")
public void _profile(ProfileOptions options) throws Exception {
Profiles profiles = new Profiles(this, options);
CommandLine cmd = options._command();
cmd.subCmd(options, profiles);
getInfo(profiles);
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _action.
@Description("Execute an action on a repo, or if no name is give, list the actions")
public void _action(ActionOptions opts) throws Exception {
Project project = getProject(opts.project());
if (project == null) {
error("Not in a project directory");
return;
}
Glob filter = opts.filter();
if (filter == null)
filter = new Glob("*");
List<Actionable> actionables = project.getPlugins(Actionable.class);
if (actionables.isEmpty()) {
error("No actionables in [%s]", project.getPlugins());
return;
}
for (Actionable o : actionables) {
if (filter.matcher(o.title()).matches()) {
logger.debug("actionable {} - {}", o, o.title());
Map<String, Runnable> map = o.actions();
if (map != null) {
if (opts._arguments().isEmpty()) {
out.printf("# %s%n", o.title());
if (opts.tooltip() && o.tooltip() != null) {
out.printf("%s%n", o.tooltip());
}
out.printf("## actions%n");
for (String entry : map.keySet()) {
out.printf(" %s%n", entry);
}
} else {
for (String entry : opts._arguments()) {
Runnable r = map.get(entry);
if (r != null) {
r.run();
}
}
}
}
}
}
getInfo(project);
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _macro.
/**
* Show the value of a macro
*
* @throws Exception
*/
@Description("Show macro value")
public void _macro(macroOptions options) throws Exception {
Project project = getProject(options.project());
if (project == null) {
messages.NoProject();
return;
}
StringBuilder sb = new StringBuilder();
Macro r = project.getReplacer();
getInfo(project);
String del = "";
for (String s : options._arguments()) {
if (!s.startsWith("${")) {
s = "${" + s;
}
if (!s.endsWith("}")) {
s += "}";
}
s = s.replace(':', ';');
String p = r.process(s);
sb.append(del);
sb.append(p);
del = " ";
}
getInfo(project);
err.println(sb);
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _debug.
/**
* Printout all the variables in scope.
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
@Description("Show a lot of info about the project you're in")
public void _debug(debugOptions options) throws Exception {
Project project = getProject(options.project());
Justif justif = new Justif(120, 40, 50, 52, 80);
logger.debug("using {}", project);
Processor target = project;
if (project != null) {
Workspace ws = project.getWorkspace();
ws.checkStructure();
getInfo(project.getWorkspace());
report(justif, "Workspace", project.getWorkspace());
report(justif, "Project", project);
if (project.getSubBuilders() != null)
for (Builder sub : project.getSubBuilders()) {
report(justif, "Sub-Builder", sub);
getInfo(sub);
}
for (File file : project.getBase().listFiles()) {
if (file.getName().endsWith(Constants.DEFAULT_BNDRUN_EXTENSION)) {
Run run = Workspace.getRun(file);
if (run == null) {
error("No such run file %s", file);
} else {
report(justif, "bndrun", run);
getInfo(run);
}
}
}
if (options.flattened()) {
@SuppressWarnings("rawtypes") Map fp = project.getFlattenedProperties();
Justif j = new Justif(140, 40, 44, 48, 100);
j.table(fp, "-");
out.println(j.wrap());
}
getInfo(project.getWorkspace());
getInfo(project);
} else
err.println("No project");
}
use of aQute.lib.getopt.Description in project bnd by bndtools.
the class bnd method _version.
/**
* Show the version of this bnd
*
* @throws IOException
*/
@Description("Show version information about bnd")
public void _version(versionOptions o) throws IOException {
if (!o.xtra()) {
Analyzer a = new Analyzer();
out.println(a.getBndVersion());
a.close();
return;
}
Enumeration<URL> e = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
while (e.hasMoreElements()) {
URL u = e.nextElement();
Manifest m = new Manifest(u.openStream());
String bsn = m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
if (bsn != null && bsn.equals("biz.aQute.bnd")) {
Attributes attrs = m.getMainAttributes();
long lastModified = 0;
try {
lastModified = Long.parseLong(attrs.getValue(Constants.BND_LASTMODIFIED));
} catch (Exception ee) {
// Ignore
}
out.printf("%-40s %s\n", "Version", attrs.getValue(Constants.BUNDLE_VERSION));
if (lastModified > 0)
out.printf("%-40s %s\n", "From", new Date(lastModified));
Parameters p = OSGiHeader.parseHeader(attrs.getValue(Constants.BUNDLE_LICENSE));
for (String l : p.keySet()) out.printf("%-40s %s\n", "License", p.get(l).get("description"));
out.printf("%-40s %s\n", "Copyright", attrs.getValue(Constants.BUNDLE_COPYRIGHT));
out.printf("%-40s %s\n", "Git-SHA", attrs.getValue("Git-SHA"));
out.printf("%-40s %s\n", "Git-Descriptor", attrs.getValue("Git-Descriptor"));
out.printf("%-40s %s\n", "Sources", attrs.getValue("Bundle-SCM"));
return;
}
}
error("Could not locate version");
}
Aggregations