From a5a627dea5f777a464a46a670d707e8bbeafd1a2 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 22 Aug 2012 15:03:07 +0200 Subject: [PATCH] enhance help --- daemon/commands/audio-codec-set.cc | 2 +- daemon/commands/help.cc | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/daemon/commands/audio-codec-set.cc b/daemon/commands/audio-codec-set.cc index 81b340b16..ca907bfe0 100644 --- a/daemon/commands/audio-codec-set.cc +++ b/daemon/commands/audio-codec-set.cc @@ -6,7 +6,7 @@ using namespace std; AudioCodecSetCommand::AudioCodecSetCommand() : - DaemonCommand("audio-codec-set", "audio-codec-set ", "Set a property(number,clock_rate, recv_fmtp, send_fmtp) of a codec") { + DaemonCommand("audio-codec-set", "audio-codec-set ", "Set a property (number,clock_rate, recv_fmtp, send_fmtp) of a codec. Numbering of payload type is automatically performed at startup, any change will be loosed after restart.") { } static PayloadType *findPayload(LinphoneCore *lc, int payload_type, int *index){ diff --git a/daemon/commands/help.cc b/daemon/commands/help.cc index 68108a510..cbb0a9e6a 100644 --- a/daemon/commands/help.cc +++ b/daemon/commands/help.cc @@ -3,15 +3,27 @@ using namespace std; HelpCommand::HelpCommand() : - DaemonCommand("help", "help", "Show available commands.") { + DaemonCommand("help", "help ", "Show help notice, if command is unspecified or inexistent show all commands.") { } void HelpCommand::exec(Daemon *app, const char *args) { - char str[4096] = { 0 }; + char str[16384] = { 0 }; int written = 0; list::const_iterator it; const list &l = app->getCommandList(); - for (it = l.begin(); it != l.end(); ++it) { - written += snprintf(str + written, sizeof(str) - written, "%s\t%s\n", (*it)->getProto().c_str(), (*it)->getHelp().c_str()); + if (args){ + for (it = l.begin(); it != l.end(); ++it) { + if ((*it)->matches(args)){ + written += snprintf(str + written, sizeof(str)-1 - written, "\t%s\n%s\n", (*it)->getProto().c_str(),(*it)->getHelp().c_str()); + break; + } + } + if (it==l.end()) args=NULL; + } + + if (args==NULL){ + for (it = l.begin(); it != l.end(); ++it) { + written += snprintf(str + written, sizeof(str)-1 - written, "\t%s\n", (*it)->getProto().c_str()); + } } Response resp; resp.setBody(str);