Skip to content

Commit

Permalink
Show command help text in chip-tool cluster listings. (#25825)
Browse files Browse the repository at this point in the history
Also adds help text for the close-session command.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Sep 6, 2023
1 parent f20c69d commit 1547232
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions examples/chip-tool/commands/common/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,23 @@ void Commands::ShowCluster(std::string executable, std::string clusterName, Comm
if (shouldPrint)
{
fprintf(stderr, " | * %-82s|\n", command->GetName());
const char * helpText = command->GetHelpText();
if (command->GetHelpText())
{
// We leave 82 chars for command names. The help text starts
// two chars further to the right, so there are 80 chars left
// for it.
if (strlen(helpText) > 80)
{
// Add "..." at the end to indicate truncation, and only
// show the first 77 chars, since that's what will fit.
fprintf(stderr, " | - %.77s...|\n", helpText);
}
else
{
fprintf(stderr, " | - %-80s|\n", helpText);
}
}
}
}
fprintf(stderr, " +-------------------------------------------------------------------------------------+\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/pairing/CloseSessionCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class CloseSessionCommand : public CHIPCommand
{
public:
CloseSessionCommand(CredentialIssuerCommands * credIssuerCommands) :
CHIPCommand("close-session", credIssuerCommands), mOnDeviceConnectedCallback(OnDeviceConnectedFn, this),
mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureFn, this)
CHIPCommand("close-session", credIssuerCommands, "Sends a CloseSession message to the given destination node id."),
mOnDeviceConnectedCallback(OnDeviceConnectedFn, this), mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureFn, this)
{
AddArgument("destination-id", 0, UINT64_MAX, &mDestinationId);
AddArgument("timeout", 0, UINT64_MAX, &mTimeoutSecs,
Expand Down

0 comments on commit 1547232

Please sign in to comment.