diff --git a/src/commands/CmdColumns.cpp b/src/commands/CmdColumns.cpp index f294a126e..7ccf7cc3c 100644 --- a/src/commands/CmdColumns.cpp +++ b/src/commands/CmdColumns.cpp @@ -59,7 +59,7 @@ int CmdColumns::execute (std::string& output) std::sort (names.begin (), names.end ()); - // Render a list of project names from the map. + // Render a list of column names, formats and examples. ViewText formats; formats.width (context.getWidth ()); formats.add (Column::factory ("string", STRING_COLUMN_LABEL_COLUMN)); @@ -95,3 +95,32 @@ int CmdColumns::execute (std::string& output) } //////////////////////////////////////////////////////////////////////////////// +CmdCompletionColumns::CmdCompletionColumns () +{ + _keyword = "_columns"; + _usage = "task _columns"; + _description = STRING_CMD_COLUMNS_USAGE2; + _read_only = true; + _displays_id = false; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdCompletionColumns::execute (std::string& output) +{ + // Include all columns. + std::vector names; + std::map ::const_iterator col; + for (col = context.columns.begin (); col != context.columns.end (); ++col) + names.push_back (col->first); + + std::sort (names.begin (), names.end ()); + + // Render only the column names. + std::vector ::iterator name; + for (name = names.begin (); name != names.end (); ++name) + output += *name + "\n"; + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdColumns.h b/src/commands/CmdColumns.h index 517489673..4b0acaf71 100644 --- a/src/commands/CmdColumns.h +++ b/src/commands/CmdColumns.h @@ -38,5 +38,12 @@ public: int execute (std::string&); }; +class CmdCompletionColumns : public Command +{ +public: + CmdCompletionColumns (); + int execute (std::string&); +}; + #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index bb3eba2ee..b4e87d0f3 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -104,6 +104,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 CmdCompletionColumns (); all[c->keyword ()] = c; c = new CmdCompletionCommands (); all[c->keyword ()] = c; c = new CmdCompletionConfig (); all[c->keyword ()] = c; c = new CmdCompletionIds (); all[c->keyword ()] = c; diff --git a/src/en-US.h b/src/en-US.h index b81a8c47f..0bb1ee4e0 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -302,6 +302,7 @@ #define STRING_CMD_ANNO_SUMMARY_N "Annotated {1} tasks." #define STRING_CMD_COLUMNS_USAGE "Displays supported columns and styles." #define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optionsl. For example, 'due' and 'due.formatted' are equivalent." +#define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns." // Config #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."