org.etlunit.cli.VersionsCmd Maven / Gradle / Ivy
package org.etlunit.cli;
import org.clamshellcli.api.Command;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
import org.codehaus.plexus.util.StringUtils;
import org.etlunit.util.IOUtils;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.*;
public class VersionsCmd implements Command {
private static final String NAMESPACE = "syscmd";
public static final String ACTION_NAME = "versions";
public Object execute(Context ctx) {
IOConsole console = ctx.getIoConsole();
try
{
Enumeration props = getClass().getClassLoader().getResources("META-INF/version/etlunit.module.properties");
while (props.hasMoreElements())
{
URL ele = props.nextElement();
String modProps = IOUtils.readURLToString(ele);
Properties propsF = new Properties();
propsF.load(new StringReader(modProps));
// print the group and artifact id specially
console.writeOutput(propsF.getProperty("projectGroupId") + "." + propsF.getProperty("projectArtifactId") + "\n");
Enumeration names = (Enumeration) propsF.propertyNames();
while (names.hasMoreElements())
{
String name = names.nextElement();
if (name.equals("projectArtifactId") || name.equals("projectGroupId"))
{
continue;
}
console.writeOutput("\t" + StringUtils.rightPad(name + ":", 20) + propsF.getProperty(name) + "\n");
}
console.writeOutput("\n");
}
}
catch (IOException e)
{
throw new IllegalArgumentException(e);
}
return null;
}
public void plug(Context plug) {
// no load-time setup needed
}
public Descriptor getDescriptor(){
return new Descriptor() {
public String getNamespace() {return NAMESPACE;}
public String getName() {
return ACTION_NAME;
}
public String getDescription() {
return "Prints the version info of all installed etlunit modules";
}
public String getUsage() {
return "versions";
}
public Map getArguments() {
return Collections.emptyMap();
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy