Mercurial > irccd
changeset 352:aab46e17cb27
Irccdctl: show help usage about command
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 14 Nov 2016 18:35:34 +0100 |
parents | 15da984ce7ea |
children | b59767d7f3d3 |
files | irccdctl/main.cpp |
diffstat | 1 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/irccdctl/main.cpp Mon Nov 14 13:32:38 2016 +0100 +++ b/irccdctl/main.cpp Mon Nov 14 18:35:34 2016 +0100 @@ -81,6 +81,21 @@ std::exit(1); } +void help(const std::string &command) +{ + auto it = std::find_if(commands.begin(), commands.end(), [&] (const auto &c) { + return c->name() == command; + }); + + if (it == commands.end()) { + log::warning() << "no command named " << command << std::endl; + } else { + log::warning() << (*it)->help() << std::endl; + } + + std::exit(1); +} + /* * Configuration file parsing. * ------------------------------------------------------------------- @@ -539,7 +554,10 @@ // NOTREACHED } if (std::strcmp(argv[0], "help") == 0) { - help(); + if (argc >= 2) + help(argv[1]); + else + help(); // NOTREACHED }