CmdCommands: Added 'commands' command to show command internal details

This commit is contained in:
Paul Beckingham 2015-08-01 15:47:21 -04:00
parent 234ad3d03b
commit d390433ec7
12 changed files with 212 additions and 12 deletions

View file

@ -29,12 +29,95 @@
#include <algorithm>
#include <stdlib.h>
#include <Context.h>
#include <ViewText.h>
#include <Command.h>
#include <CmdCommands.h>
#include <ColString.h>
#include <text.h>
#include <i18n.h>
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 ()
{
@ -43,6 +126,11 @@ CmdCompletionCommands::CmdCompletionCommands ()
_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;
}
@ -74,6 +162,11 @@ CmdZshCommands::CmdZshCommands ()
_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;
}

View file

@ -30,6 +30,13 @@
#include <string>
#include <Command.h>
class CmdCommands : public Command
{
public:
CmdCommands ();
int execute (std::string&);
};
class CmdCompletionCommands : public Command
{
public:

View file

@ -106,6 +106,7 @@ void Command::factory (std::map <std::string, Command*>& 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;

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -229,6 +229,16 @@
#define STRING_COLUMN_LABEL_UDACOUNT "Compte dutilisation"
#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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"