From 14c09c042965368aae1715feef9c894a6d724d49 Mon Sep 17 00:00:00 2001 From: Michael Davis <michael.davis@cern.ch> Date: Wed, 22 Jul 2020 15:44:59 +0200 Subject: [PATCH] [cta-admin] Lists help commands in alphabetic order --- cmdline/CtaAdminCmd.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmdline/CtaAdminCmd.cpp b/cmdline/CtaAdminCmd.cpp index f4b178c0c3..1f46abede8 100644 --- a/cmdline/CtaAdminCmd.cpp +++ b/cmdline/CtaAdminCmd.cpp @@ -461,21 +461,21 @@ void CtaAdminCmd::throwUsage(const std::string &error_txt) const if(admincmd == AdminCmd::CMD_NONE) { // Command has not been set: show generic help - help << "CTA Admin commands:" << std::endl << std::endl << "For each command there is a short version and a long one. Subcommands (add/ch/ls/rm/etc.)" << std::endl << "do not have short versions. For detailed help on the options of each subcommand, type:" << std::endl << " " << m_execname << " <command> help" << std::endl << std::endl; - for(auto cmd_it = cmdHelp.begin(); cmd_it != cmdHelp.end(); ++cmd_it) - { - help << " " << m_execname << ' ' << cmd_it->second.short_help() << std::endl; + // List help for each command in lexicographic order + std::set<std::string> helpSet; + for(auto &helpPair : cmdHelp) { + helpSet.insert(helpPair.second.short_help()); } - } - else - { + for(auto &helpItem : helpSet) { + help << " " << m_execname << ' ' << helpItem << std::endl; + } + } else { // Command has been set: show command-specific help - help << m_execname << ' ' << cmdHelp.at(admincmd).help(); } -- GitLab