mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Helper Command
- Implemented _columns to simply list all supported columns, in a machine-readable format.
This commit is contained in:
parent
27a04b29f5
commit
05a53778ea
4 changed files with 39 additions and 1 deletions
|
@ -59,7 +59,7 @@ int CmdColumns::execute (std::string& output)
|
||||||
|
|
||||||
std::sort (names.begin (), names.end ());
|
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;
|
ViewText formats;
|
||||||
formats.width (context.getWidth ());
|
formats.width (context.getWidth ());
|
||||||
formats.add (Column::factory ("string", STRING_COLUMN_LABEL_COLUMN));
|
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 <std::string> names;
|
||||||
|
std::map <std::string, Column*>::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 <std::string>::iterator name;
|
||||||
|
for (name = names.begin (); name != names.end (); ++name)
|
||||||
|
output += *name + "\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,5 +38,12 @@ public:
|
||||||
int execute (std::string&);
|
int execute (std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CmdCompletionColumns : public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CmdCompletionColumns ();
|
||||||
|
int execute (std::string&);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -104,6 +104,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
c = new CmdCalendar (); all[c->keyword ()] = c;
|
c = new CmdCalendar (); all[c->keyword ()] = c;
|
||||||
c = new CmdColor (); all[c->keyword ()] = c;
|
c = new CmdColor (); all[c->keyword ()] = c;
|
||||||
c = new CmdColumns (); 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 CmdCompletionCommands (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionConfig (); all[c->keyword ()] = c;
|
c = new CmdCompletionConfig (); all[c->keyword ()] = c;
|
||||||
c = new CmdCompletionIds (); all[c->keyword ()] = c;
|
c = new CmdCompletionIds (); all[c->keyword ()] = c;
|
||||||
|
|
|
@ -302,6 +302,7 @@
|
||||||
#define STRING_CMD_ANNO_SUMMARY_N "Annotated {1} tasks."
|
#define STRING_CMD_ANNO_SUMMARY_N "Annotated {1} tasks."
|
||||||
#define STRING_CMD_COLUMNS_USAGE "Displays supported columns and styles."
|
#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_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
|
// Config
|
||||||
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."
|
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue