CmdCommands: Code cleanup
This commit is contained in:
@@ -85,7 +85,7 @@ int CmdCommands::execute (std::string& output)
|
|||||||
|
|
||||||
for (auto& command : context.commands)
|
for (auto& command : context.commands)
|
||||||
{
|
{
|
||||||
int row = view.addRow ();
|
auto row = view.addRow ();
|
||||||
view.set (row, 0, command.first);
|
view.set (row, 0, command.first);
|
||||||
view.set (row, 1, Command::categoryNames.at (command.second->category ()));
|
view.set (row, 1, Command::categoryNames.at (command.second->category ()));
|
||||||
|
|
||||||
@@ -144,15 +144,14 @@ int CmdCompletionCommands::execute (std::string& output)
|
|||||||
{
|
{
|
||||||
// Get a list of all commands.
|
// Get a list of all commands.
|
||||||
std::vector <std::string> commands;
|
std::vector <std::string> commands;
|
||||||
|
for (const auto& command : context.commands)
|
||||||
for (auto& command : context.commands)
|
|
||||||
commands.push_back (command.first);
|
commands.push_back (command.first);
|
||||||
|
|
||||||
// Sort alphabetically.
|
// Sort alphabetically.
|
||||||
std::sort (commands.begin (), commands.end ());
|
std::sort (commands.begin (), commands.end ());
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (auto& c : commands)
|
for (const auto& c : commands)
|
||||||
out << c << '\n';
|
out << c << '\n';
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
@@ -179,6 +178,7 @@ CmdZshCommands::CmdZshCommands ()
|
|||||||
struct ZshCommand
|
struct ZshCommand
|
||||||
{
|
{
|
||||||
bool operator< (const struct ZshCommand&) const;
|
bool operator< (const struct ZshCommand&) const;
|
||||||
|
|
||||||
Command::Category _category;
|
Command::Category _category;
|
||||||
std::string _command;
|
std::string _command;
|
||||||
std::string _description;
|
std::string _description;
|
||||||
@@ -222,7 +222,7 @@ int CmdZshCommands::execute (std::string& output)
|
|||||||
|
|
||||||
// Emit the commands in order.
|
// Emit the commands in order.
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (auto& zc : commands)
|
for (const auto& zc : commands)
|
||||||
out << zc._command << ':'
|
out << zc._command << ':'
|
||||||
<< Command::categoryNames.at (zc._category) << ':'
|
<< Command::categoryNames.at (zc._category) << ':'
|
||||||
<< zc._description << '\n';
|
<< zc._description << '\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user