super("command", true);
this.cmdRegistry = cmdRegistry;
action.addCantAppearAfter(helpArg);
nodePath = new ArgumentWithValue(this, new CommandLineCompleter(){
@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
int offset = 0;
int result = OperationRequestCompleter.ARG_VALUE_COMPLETER.complete(ctx, buffer, cursor + offset, candidates) - offset;
if(result < 0) {
return result;
}
return result;
}}, "--node-type") {
@Override
public boolean canAppearNext(CommandContext ctx) throws CommandFormatException {
return "add".equals(action.getValue(ctx.getParsedCommandLine())) && super.canAppearNext(ctx);
}
};
idProperty = new ArgumentWithValue(this, new DefaultCompleter(new CandidatesProvider(){
@Override
public List<String> getAllCandidates(CommandContext ctx) {
List<Property> props = getNodeProperties(ctx);
if(props.isEmpty()) {
return Collections.emptyList();
}
final List<String> candidates = new ArrayList<String>();
for(Property prop : props) {
final ModelNode value = prop.getValue();
if(value.has("access-type") && "read-only".equals(value.get("access-type").asString())) {
candidates.add(prop.getName());
}
}
return candidates;
}}), "--property-id");
idProperty.addRequiredPreceding(nodePath);
commandName = new ArgumentWithValue(this, new DefaultCompleter(new CandidatesProvider(){
private final DefaultCallbackHandler callback = new DefaultCallbackHandler();
@Override
public List<String> getAllCandidates(CommandContext ctx) {