
org.etlunit.cli.SetCmd Maven / Gradle / Ivy
package org.etlunit.cli;
import org.clamshellcli.api.Command;
import org.clamshellcli.api.Configurator;
import org.clamshellcli.api.Context;
import org.clamshellcli.api.IOConsole;
import org.etlunit.feature.Feature;
import org.etlunit.feature.RuntimeOptionDescriptor;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SetCmd implements Command {
private static final String NAMESPACE = "syscmd";
public static final String ACTION_NAME = "set";
public Object execute(Context ctx) {
IOConsole console = ctx.getIoConsole();
String [] inputLine = (String []) ctx.getValue(Context.KEY_COMMAND_LINE_ARGS);
String featureName = null;
if (inputLine != null && inputLine.length == 1)
{
featureName = inputLine[0];
}
try {
List list = ListAvailableFeaturesCmd.getAvailableFeatures();
for (Feature f : list)
{
if (featureName != null)
{
if (!featureName.equals(f.getFeatureName()))
{
continue;
}
}
List opList = f.getMetaInfo().getOptions();
if (opList != null && opList.size() > 0)
{
console.writeOutput(f.getFeatureName() + ":" + Configurator.VALUE_LINE_SEP);
for (RuntimeOptionDescriptor option : opList)
{
console.writeOutput("\t" + option.getName() + " - " + option.getDescription() + Configurator.VALUE_LINE_SEP);
switch (option.getOptionType())
{
case bool:
console.writeOutput("\t\tEnabled: " + option.getDefaultBooleanValue() + Configurator.VALUE_LINE_SEP);
break;
case integer:
console.writeOutput("\t\tValue: " + option.getDefaultIntegerValue() + Configurator.VALUE_LINE_SEP);
break;
case string:
console.writeOutput("\t\tValue: " + option.getDefaultStringValue() + Configurator.VALUE_LINE_SEP);
break;
}
}
}
}
} catch (Exception exc) {
console.writeOutput(exc.toString() + Configurator.VALUE_LINE_SEP);
exc.printStackTrace(System.out);
}
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 "Displays or sets options for system or for a feature";
}
public String getUsage() {
return "Type [featureName]";
}
public Map getArguments() {
Map map = new HashMap();
map.put("feature", "Optional feature name");
return map;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy