CRecordCliGetHelp

This message is sent from the console display target to the console service to obtain help output for the registered commands.

The message is part of the console API. It is a nanoservice in the SYSTEM namespace.

{
  "id": "a53b0278-48e1-48b1-9220-8cc1a4d73197",
  "name": "CLI_GET_HELP",
  "description": "Get the local help output.",
  "slots": [
    {
      "key": "1",
      "name": "HELP",
      "direction": "ANSWER",
      "mandatory": "false",
      "type": "STRING",
      "description": "The help for the local command line."
    }
  ]
}

Arguments

  • HELP is the response from the console service. It is a help text for each registered command.

Usage

Sending a request when you already have the address of the desired command service:

final CEnvelope env = CEnvelope.forSingleTarget(mAddress);
final CRecord record = CRecordCliGetHelp.create();
sendRequest(env,
            record);

Sending a request when you don't have the address of the desired command service but have a node address:

final CEnvelope env = CEnvelope.forRemoteNanoService(CRecordCliGetHelp.class,
                                                     nodeAddress);
final CRecord record = CRecordCliGetHelp.create();
sendRequest(env,
            record);

Registration of the message handler for CRecordCliGetHelp:

addMessageHandler(CRecordCliGetHelp.ID,
                  this::asyncAnswerGetHelp);

Message handler:

private boolean asyncAnswerGetHelp(@NotNull final CEnvelope aEnvelope,
                                   @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        final CResult result = aEnvelope.getResult();
        if (result.hasSuccess())
        {
            final String help = CRecordCliGetHelp.getHelp(aRecord,
                                                          "?");
            println(help);
        }
        else
        {
            final  nodeId = aEnvelope.getSender()
                                            .getNodeId();
            printError("Can't get Help from " + nodeId + ": " + result.getText());
        }
        printPrompt();
        return true;
    }
    else
    {
        return false;
    }
}

nyssr.net - Innovative Distributed System