From d390433ec7b6ad4c2ab4a6102e342db6192d9b31 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 1 Aug 2015 15:47:21 -0400 Subject: [PATCH] CmdCommands: Added 'commands' command to show command internal details --- src/commands/CmdCommands.cpp | 117 +++++++++++++++++++++++++++++++---- src/commands/CmdCommands.h | 7 +++ src/commands/Command.cpp | 1 + src/l10n/deu-DEU.h | 11 ++++ src/l10n/eng-USA.h | 11 ++++ src/l10n/epo-RUS.h | 11 ++++ src/l10n/esp-ESP.h | 11 ++++ src/l10n/fra-FRA.h | 11 ++++ src/l10n/ita-ITA.h | 11 ++++ src/l10n/jpn-JPN.h | 11 ++++ src/l10n/pol-POL.h | 11 ++++ src/l10n/por-PRT.h | 11 ++++ 12 files changed, 212 insertions(+), 12 deletions(-) diff --git a/src/commands/CmdCommands.cpp b/src/commands/CmdCommands.cpp index 025d80999..b79d736c6 100644 --- a/src/commands/CmdCommands.cpp +++ b/src/commands/CmdCommands.cpp @@ -29,21 +29,109 @@ #include #include #include +#include #include #include +#include +#include #include extern Context context; +//////////////////////////////////////////////////////////////////////////////// +CmdCommands::CmdCommands () +{ + _keyword = "commands"; + _usage = "task commands"; + _description = STRING_CMD_COMMANDS_USAGE; + _read_only = true; + _displays_id = false; + _needs_gc = false; + _uses_context = false; + _accepts_filter = false; + _accepts_modifications = false; + _accepts_miscellaneous = false; + _category = Command::Category::interrogator; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdCommands::execute (std::string& output) +{ + ViewText view; + view.width (context.getWidth ()); + view.add (Column::factory ("string", STRING_COLUMN_LABEL_COMMAND)); + view.add (Column::factory ("string", STRING_COLUMN_LABEL_CATEGORY)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_RO)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_SHOWS_ID)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_GC)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_CONTEXT)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_FILTER)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_MODS)); + view.add (Column::factory ("string.right", STRING_COLUMN_LABEL_MISC)); + + Color label (context.config.get ("color.label")); + view.colorHeader (label); + + Color alternate (context.config.get ("color.alternate")); + view.colorOdd (alternate); + view.intraColorOdd (alternate); + + view.leftMargin (context.config.getInteger ("indent.report")); + view.extraPadding (context.config.getInteger ("row.padding")); + view.intraPadding (context.config.getInteger ("column.padding")); + + for (auto& command : context.commands) + { + int row = view.addRow (); + view.set (row, 0, command.first); + view.set (row, 1, Command::categoryNames.at (command.second->_category)); + + if (command.second->read_only ()) + view.set (row, 2, "RO"); + else + view.set (row, 2, "RW"); + + if (command.second->displays_id ()) + view.set (row, 3, "ID"); + + if (command.second->needs_gc ()) + view.set (row, 4, "GC"); + + if (command.second->uses_context ()) + view.set (row, 5, "Context"); + + if (command.second->accepts_filter ()) + view.set (row, 6, "Filter"); + + if (command.second->accepts_modifications ()) + view.set (row, 7, "Modifications"); + + if (command.second->accepts_miscellaneous ()) + view.set (row, 8, "Args"); + } + + output = optionalBlankLine () + + view.render () + + optionalBlankLine () + + "\n"; + + return 0; +} + //////////////////////////////////////////////////////////////////////////////// CmdCompletionCommands::CmdCompletionCommands () { - _keyword = "_commands"; - _usage = "task _commands"; - _description = STRING_CMD_HCOMMANDS_USAGE; - _read_only = true; - _displays_id = false; - _category = Command::Category::internal; + _keyword = "_commands"; + _usage = "task _commands"; + _description = STRING_CMD_HCOMMANDS_USAGE; + _read_only = true; + _displays_id = false; + _needs_gc = false; + _uses_context = false; + _accepts_filter = false; + _accepts_modifications = false; + _accepts_miscellaneous = false; + _category = Command::Category::internal; } //////////////////////////////////////////////////////////////////////////////// @@ -69,12 +157,17 @@ int CmdCompletionCommands::execute (std::string& output) //////////////////////////////////////////////////////////////////////////////// CmdZshCommands::CmdZshCommands () { - _keyword = "_zshcommands"; - _usage = "task _zshcommands"; - _description = STRING_CMD_ZSHCOMMANDS_USAGE; - _read_only = true; - _displays_id = false; - _category = Command::Category::internal; + _keyword = "_zshcommands"; + _usage = "task _zshcommands"; + _description = STRING_CMD_ZSHCOMMANDS_USAGE; + _read_only = true; + _displays_id = false; + _needs_gc = false; + _uses_context = false; + _accepts_filter = false; + _accepts_modifications = false; + _accepts_miscellaneous = false; + _category = Command::Category::internal; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdCommands.h b/src/commands/CmdCommands.h index 3afb94485..cfc95641f 100644 --- a/src/commands/CmdCommands.h +++ b/src/commands/CmdCommands.h @@ -30,6 +30,13 @@ #include #include +class CmdCommands : public Command +{ +public: + CmdCommands (); + int execute (std::string&); +}; + class CmdCompletionCommands : public Command { public: diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 03ec8bde3..f99708435 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -106,6 +106,7 @@ void Command::factory (std::map & all) c = new CmdCalendar (); all[c->keyword ()] = c; c = new CmdColor (); all[c->keyword ()] = c; c = new CmdColumns (); all[c->keyword ()] = c; + c = new CmdCommands (); all[c->keyword ()] = c; c = new CmdCompletionAliases (); all[c->keyword ()] = c; c = new CmdCompletionColumns (); all[c->keyword ()] = c; c = new CmdCompletionCommands (); all[c->keyword ()] = c; diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index 065096651..acaff2ad7 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Nutzungshäufigkeit" #define STRING_COLUMN_LABEL_ORPHAN "Verwaiste UDA" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "Haus @Hausarbeit next" #define STRING_COLUMN_EXAMPLES_PROJ "Haus.Garten" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Erzeugt eine Liste aller Befehle zur Auto-Vervollständigung" #define STRING_CMD_ZSHCOMMANDS_USAGE "Erzeugt eine Liste aller Befehle zur ZSH-Auto-Verfollständigung" #define STRING_CMD_ZSHATTS_USAGE "Erzeugt eine Liste Eigenschaften zur ZSH-Auto-Vervollständigung" diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index d474ef083..3e79294ba 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Usage Count" #define STRING_COLUMN_LABEL_ORPHAN "Orphan UDA" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "home @chore next" #define STRING_COLUMN_EXAMPLES_PROJ "home.garden" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Generates a list of all commands, for autocompletion purposes" #define STRING_CMD_ZSHCOMMANDS_USAGE "Generates a list of all commands, for zsh autocompletion purposes" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index 06c256528..53a5edb41 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Nombro de uzoj" #define STRING_COLUMN_LABEL_ORPHAN "Orfa UDA" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "domo @aĉo next" #define STRING_COLUMN_EXAMPLES_PROJ "domo.ĝardeno" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Generates a list of all commands, for autocompletion purposes" #define STRING_CMD_ZSHCOMMANDS_USAGE "Generates a list of all commands, for zsh autocompletion purposes" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index 77b2bbef0..0206eb22e 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -230,6 +230,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Recuento de uso" #define STRING_COLUMN_LABEL_ORPHAN "UDA huérfano" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "casa @tarea" #define STRING_COLUMN_EXAMPLES_PROJ "casa.jardín" @@ -510,6 +520,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Habilitado" #define STRING_CMD_DIAG_HOOK_DISABLE "Inhabilitado" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Genera una lista de todos los comandos, con fines de auto-completado" #define STRING_CMD_ZSHCOMMANDS_USAGE "Genera una lista de todos los comandos, con fines de auto-completado zsh" diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index 755dbe9dd..62b1cc674 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Compte d’utilisation" #define STRING_COLUMN_LABEL_ORPHAN "ADU orphelins" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "maison @routine next" #define STRING_COLUMN_EXAMPLES_PROJ "maison.jardin" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Generates a list of all commands, for autocompletion purposes" #define STRING_CMD_ZSHCOMMANDS_USAGE "Generates a list of all commands, for zsh autocompletion purposes" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index 5f4f130dc..ecc733973 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Conteggio Uso" #define STRING_COLUMN_LABEL_ORPHAN "UDA Orfano" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "casa @faccende next" #define STRING_COLUMN_EXAMPLES_PROJ "casa.giardino" @@ -501,6 +511,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Genera la lista di tutti i comandi, per autocompletamento" #define STRING_CMD_ZSHCOMMANDS_USAGE "Genera la lista di tutti i comandi, per autocompletamento in zsh" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index be211764e..5f8831a59 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Usage Count" #define STRING_COLUMN_LABEL_ORPHAN "Orphan UDA" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "home @chore next" #define STRING_COLUMN_EXAMPLES_PROJ "home.garden" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Generates a list of all commands, for autocompletion purposes" #define STRING_CMD_ZSHCOMMANDS_USAGE "Generates a list of all commands, for zsh autocompletion purposes" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index 5f2725c22..359d0e206 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -229,6 +229,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Licznik Użycia" #define STRING_COLUMN_LABEL_ORPHAN "Osierocone UDA" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "home @chore next" #define STRING_COLUMN_EXAMPLES_PROJ "dom.ogród" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Generuje listę wszystkich poleceń dla funkcji autouzupełniania" #define STRING_CMD_ZSHCOMMANDS_USAGE "Generuje listę wszystkich poleceń dla funkcji autouzupełniania w powłoce zsh" #define STRING_CMD_ZSHATTS_USAGE "Generates a list of all attributes, for zsh autocompletion purposes" diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index 414eb9139..3a1b65019 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -230,6 +230,16 @@ #define STRING_COLUMN_LABEL_UDACOUNT "Contagem de Uso" #define STRING_COLUMN_LABEL_ORPHAN "UDA Orfão" +#define STRING_COLUMN_LABEL_COMMAND "Command" +#define STRING_COLUMN_LABEL_CATEGORY "Category" +#define STRING_COLUMN_LABEL_RO "R/W" +#define STRING_COLUMN_LABEL_SHOWS_ID "ID?" +#define STRING_COLUMN_LABEL_GC "GC?" +#define STRING_COLUMN_LABEL_CONTEXT "Context?" +#define STRING_COLUMN_LABEL_FILTER "Filter?" +#define STRING_COLUMN_LABEL_MODS "Mods?" +#define STRING_COLUMN_LABEL_MISC "Other?" + // Column Examples #define STRING_COLUMN_EXAMPLES_TAGS "casa @contas próxima" #define STRING_COLUMN_EXAMPLES_PROJ "casa.jardim" @@ -502,6 +512,7 @@ #define STRING_CMD_DIAG_HOOK_ENABLE "Enabled" #define STRING_CMD_DIAG_HOOK_DISABLE "Disabled" +#define STRING_CMD_COMMANDS_USAGE "Generates a list of all commands, with behavior details" #define STRING_CMD_HCOMMANDS_USAGE "Gera uma lista com todos os comandos, para fins de terminação automática" #define STRING_CMD_ZSHCOMMANDS_USAGE "Gera uma lista com todos os comandos, para terminação automática em zsh" #define STRING_CMD_ZSHATTS_USAGE "Gera uma lista de todos os atributos, para terminação automática em zsh"