mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 18:06:42 +02:00
Feature #1061
- Added Feature #1061, which allows the 'columns' command to use a search string for the column name (thanks to Uli Martens).
This commit is contained in:
parent
d8579730f5
commit
12b12c3a62
8 changed files with 92 additions and 13 deletions
|
@ -42,7 +42,7 @@ extern Context context;
|
|||
CmdColumns::CmdColumns ()
|
||||
{
|
||||
_keyword = "columns";
|
||||
_usage = "task columns";
|
||||
_usage = "task columns [substring]";
|
||||
_description = STRING_CMD_COLUMNS_USAGE;
|
||||
_read_only = true;
|
||||
_displays_id = false;
|
||||
|
@ -51,6 +51,12 @@ CmdColumns::CmdColumns ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdColumns::execute (std::string& output)
|
||||
{
|
||||
// Obtain the arguments from the description. That way, things like '--'
|
||||
// have already been handled.
|
||||
std::vector <std::string> words = context.a3.extract_words ();
|
||||
if (words.size () > 1)
|
||||
throw std::string (STRING_CMD_COLUMNS_ARGS);
|
||||
|
||||
// Include all columns in the table.
|
||||
std::vector <std::string> names;
|
||||
std::map <std::string, Column*>::const_iterator col;
|
||||
|
@ -73,15 +79,19 @@ int CmdColumns::execute (std::string& output)
|
|||
std::vector <std::string>::iterator name;
|
||||
for (name = names.begin (); name != names.end (); ++name)
|
||||
{
|
||||
const std::vector <std::string> styles = context.columns[*name]->styles ();
|
||||
const std::vector <std::string> examples = context.columns[*name]->examples ();
|
||||
|
||||
for (unsigned int i = 0; i < styles.size (); ++i)
|
||||
if (words.size () == 0 ||
|
||||
find (*name, words[0], false) != std::string::npos)
|
||||
{
|
||||
int row = formats.addRow ();
|
||||
formats.set (row, 0, i == 0 ? *name : "");
|
||||
formats.set (row, 1, styles[i] + (i == 0 ? "*" : ""));
|
||||
formats.set (row, 2, i < examples.size () ? examples[i] : "");
|
||||
const std::vector <std::string> styles = context.columns[*name]->styles ();
|
||||
const std::vector <std::string> examples = context.columns[*name]->examples ();
|
||||
|
||||
for (unsigned int i = 0; i < styles.size (); ++i)
|
||||
{
|
||||
int row = formats.addRow ();
|
||||
formats.set (row, 0, i == 0 ? *name : "");
|
||||
formats.set (row, 1, styles[i] + (i == 0 ? "*" : ""));
|
||||
formats.set (row, 2, i < examples.size () ? examples[i] : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -388,6 +388,7 @@
|
|||
#define STRING_CMD_COLUMNS_USAGE "All supported columns and formatting styles"
|
||||
#define STRING_CMD_COLUMNS_NOTE "* Means default format, and therefore optional. For example, 'due' and 'due.formatted' are equivalent."
|
||||
#define STRING_CMD_COLUMNS_USAGE2 "Displays only a list of supported columns"
|
||||
#define STRING_CMD_COLUMNS_ARGS "You can only specify one search string."
|
||||
|
||||
#define STRING_CMD_DENO_USAGE "Deletes an annotation"
|
||||
#define STRING_CMD_DENO_WORDS "An annotation pattern must be provided."
|
||||
|
|
|
@ -398,8 +398,8 @@
|
|||
|
||||
#define STRING_CMD_COLUMNS_USAGE "Todas las columnas y estilos de formato soportados"
|
||||
#define STRING_CMD_COLUMNS_NOTE "* Significa formato por defecto, y por lo tanto opcional. Por ejemplo 'due' y 'due.formatted' son equivalentes."
|
||||
|
||||
#define STRING_CMD_COLUMNS_USAGE2 "Muestra una lista de columnas (solo nombres) soportadas"
|
||||
#define STRING_CMD_COLUMNS_ARGS "Solo puede especificar un término de búsqueda."
|
||||
|
||||
#define STRING_CMD_DENO_USAGE "Elimina una anotación"
|
||||
#define STRING_CMD_DENO_WORDS "Se debe proporcionar un patrón de anotación."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue