use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class DeploymentOverlayHandler method listContent.
protected void listContent(CommandContext ctx) throws CommandLineException {
final ModelControllerClient client = ctx.getModelControllerClient();
final ParsedCommandLine args = ctx.getParsedCommandLine();
assertNotPresent(serverGroups, args);
assertNotPresent(allServerGroups, args);
assertNotPresent(allRelevantServerGroups, args);
assertNotPresent(deployments, args);
assertNotPresent(content, args);
assertNotPresent(redeployAffected, args);
final String name = getName(ctx, true);
final List<String> content = loadContentFor(client, name);
if (l.isPresent(args)) {
for (String contentPath : content) {
ctx.printLine(contentPath);
}
} else {
ctx.printColumns(content);
}
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class LsHandler method buildRequestWithoutHeaders.
@Override
protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine();
final OperationRequestAddress address = getOperationRequestAddress(ctx);
if (address.endsOnType()) {
final String type = address.getNodeType();
address.toParentNode();
final DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder(address);
try {
builder.setOperationName(Util.READ_CHILDREN_NAMES);
builder.addProperty(Util.CHILD_TYPE, type);
return builder.buildRequest();
} catch (OperationFormatException e) {
throw new IllegalStateException("Failed to build operation", e);
}
}
final ModelNode composite = new ModelNode();
composite.get(Util.OPERATION).set(Util.COMPOSITE);
composite.get(Util.ADDRESS).setEmptyList();
final ModelNode steps = composite.get(Util.STEPS);
{
ModelNode typesRequest = new ModelNode();
typesRequest.get(Util.OPERATION).set(Util.READ_CHILDREN_TYPES);
typesRequest = getAddressNode(ctx, address, typesRequest);
steps.add(typesRequest);
}
{
ModelNode resourceRequest = new ModelNode();
resourceRequest.get(Util.OPERATION).set(Util.READ_RESOURCE);
resourceRequest = getAddressNode(ctx, address, resourceRequest);
resourceRequest.get(Util.INCLUDE_RUNTIME).set(Util.TRUE);
if (resolve.isPresent(parsedCmd)) {
resourceRequest.get(Util.RESOLVE_EXPRESSIONS).set(Util.TRUE);
}
steps.add(resourceRequest);
}
if (l.isPresent(parsedCmd)) {
steps.add(Util.buildRequest(ctx, address, Util.READ_RESOURCE_DESCRIPTION));
}
return composite;
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class LsHandler method getOperationRequestAddress.
private OperationRequestAddress getOperationRequestAddress(CommandContext ctx) throws CommandFormatException {
final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine();
String nodePathString = nodePath.getValue(parsedCmd);
final OperationRequestAddress address;
if (nodePathString != null) {
address = new DefaultOperationRequestAddress(ctx.getCurrentNodePath());
// this is for correct parsing of escaped characters
// this method could return null
nodePathString = ctx.getArgumentsString();
// but this method is useful to handle command lines with line breaks
if (nodePathString == null) {
nodePathString = parsedCmd.getOriginalLine();
int cmdNameLength = parsedCmd.getOperationName().length();
if (nodePathString.length() == cmdNameLength) {
return address;
} else {
nodePathString = nodePathString.substring(cmdNameLength + 1);
}
}
nodePathString = getNodePath(nodePathString);
final CommandLineParser.CallbackHandler handler = new DefaultCallbackHandler(address);
ctx.getCommandLineParser().parse(nodePathString, handler);
} else {
address = new DefaultOperationRequestAddress(ctx.getCurrentNodePath());
}
return address;
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class SetVariableHandler method recognizeArguments.
@Override
protected void recognizeArguments(CommandContext ctx) throws CommandFormatException {
final ParsedCommandLine args = ctx.getParsedCommandLine();
final Set<String> propertyNames = args.getPropertyNames();
if (!propertyNames.isEmpty()) {
final Collection<String> names;
if (helpArg.isPresent(args)) {
if (propertyNames.size() == 1) {
return;
}
names = new ArrayList<String>(propertyNames);
names.remove(helpArg.getFullName());
names.remove(helpArg.getShortName());
} else {
names = propertyNames;
}
throw new CommandFormatException("Unrecognized argument names: " + names);
}
}
use of org.jboss.as.cli.operation.ParsedCommandLine in project wildfly-core by wildfly.
the class ArgumentWithValue method toModelNode.
public ModelNode toModelNode(CommandContext ctx) throws CommandFormatException {
final ParsedCommandLine parsedLine = ctx.getParsedCommandLine();
final String value = getOriginalValue(parsedLine, false);
if (value == null) {
return null;
}
return valueConverter.fromString(ctx, value);
}
Aggregations