mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature: Extra arg detection
- Commands that do not accept filters or modifications now generate an error when extra arguments are specified.
This commit is contained in:
parent
8684639f72
commit
5f30c9e2c3
21 changed files with 72 additions and 0 deletions
|
@ -105,6 +105,8 @@
|
||||||
- When multiple tasks are 'edit'ed, a failure causes the editing to stop (thanks
|
- When multiple tasks are 'edit'ed, a failure causes the editing to stop (thanks
|
||||||
to Daniel Shahaf).
|
to Daniel Shahaf).
|
||||||
- New 'UDA' and 'ORPHAN' virtual tags.
|
- New 'UDA' and 'ORPHAN' virtual tags.
|
||||||
|
- Commands that do not accept filters or modifications now generate an error
|
||||||
|
when extra arguments are specified.
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <RX.h>
|
#include <RX.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -64,6 +65,12 @@ CmdDiagnostics::CmdDiagnostics ()
|
||||||
// kind of questions we always have to ask whenever something is wrong.
|
// kind of questions we always have to ask whenever something is wrong.
|
||||||
int CmdDiagnostics::execute (std::string& output)
|
int CmdDiagnostics::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
Color bold;
|
Color bold;
|
||||||
if (context.color ())
|
if (context.color ())
|
||||||
bold = Color ("bold");
|
bold = Color ("bold");
|
||||||
|
|
|
@ -56,6 +56,9 @@ int CmdExport::execute (std::string& output)
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
filter.subset (filtered, false);
|
filter.subset (filtered, false);
|
||||||
|
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
// Obey 'limit:N'.
|
// Obey 'limit:N'.
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <CmdHelp.h>
|
#include <CmdHelp.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -48,6 +49,12 @@ CmdHelp::CmdHelp ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdHelp::execute (std::string& output)
|
int CmdHelp::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
ViewText view;
|
ViewText view;
|
||||||
view.width (context.getWidth ());
|
view.width (context.getWidth ());
|
||||||
view.add (Column::factory ("string.left", ""));
|
view.add (Column::factory ("string.left", ""));
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <JSON.h>
|
#include <JSON.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -54,6 +55,10 @@ int CmdImport::execute (std::string& output)
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
|
||||||
// Get filenames from command line arguments.
|
// Get filenames from command line arguments.
|
||||||
std::vector <std::string> words = context.cli2.getWords ();
|
std::vector <std::string> words = context.cli2.getWords ();
|
||||||
if (! words.size () || (words.size () == 1 && words[0] == "-"))
|
if (! words.size () || (words.size () == 1 && words[0] == "-"))
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <CmdLogo.h>
|
#include <CmdLogo.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
|
||||||
|
@ -50,6 +51,12 @@ CmdLogo::CmdLogo ()
|
||||||
// extension.<uuid>=<JSON>
|
// extension.<uuid>=<JSON>
|
||||||
int CmdLogo::execute (std::string& output)
|
int CmdLogo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
static const char* data[] =
|
static const char* data[] =
|
||||||
{
|
{
|
||||||
".........ABDEF",
|
".........ABDEF",
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
@ -48,6 +49,12 @@ CmdReports::CmdReports ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdReports::execute (std::string& output)
|
int CmdReports::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
std::vector <std::string> reports;
|
std::vector <std::string> reports;
|
||||||
|
|
||||||
// Add custom reports.
|
// Add custom reports.
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <Color.h>
|
#include <Color.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -54,6 +55,10 @@ int CmdSync::execute (std::string& output)
|
||||||
#ifdef HAVE_LIBGNUTLS
|
#ifdef HAVE_LIBGNUTLS
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
|
||||||
// Loog for the 'init' keyword to indicate one-time pending.data upload.
|
// Loog for the 'init' keyword to indicate one-time pending.data upload.
|
||||||
bool first_time_init = false;
|
bool first_time_init = false;
|
||||||
std::vector <std::string> words = context.cli2.getWords ();
|
std::vector <std::string> words = context.cli2.getWords ();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
|
@ -71,6 +71,11 @@ int CmdUDAs::execute (std::string& output)
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
filter.subset (filtered);
|
filter.subset (filtered);
|
||||||
|
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
if (udas.size ())
|
if (udas.size ())
|
||||||
{
|
{
|
||||||
std::sort (udas.begin (), udas.end ());
|
std::sort (udas.begin (), udas.end ());
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <CmdUndo.h>
|
#include <CmdUndo.h>
|
||||||
|
|
||||||
|
@ -44,6 +45,12 @@ CmdUndo::CmdUndo ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdUndo::execute (std::string& output)
|
int CmdUndo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
// Detect attempts to modify the task.
|
// Detect attempts to modify the task.
|
||||||
if (context.cli2.getWords ().size ())
|
if (context.cli2.getWords ().size ())
|
||||||
throw std::string (STRING_CMD_UNDO_MODS);
|
throw std::string (STRING_CMD_UNDO_MODS);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Filter.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#ifdef HAVE_COMMIT
|
#ifdef HAVE_COMMIT
|
||||||
#include <commit.h>
|
#include <commit.h>
|
||||||
|
@ -51,6 +52,12 @@ CmdVersion::CmdVersion ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdVersion::execute (std::string& output)
|
int CmdVersion::execute (std::string& output)
|
||||||
{
|
{
|
||||||
|
Filter filter;
|
||||||
|
if (filter.hasFilter ())
|
||||||
|
throw std::string (STRING_ERROR_NO_FILTER);
|
||||||
|
if (filter.hasModifications ())
|
||||||
|
throw std::string (STRING_ERROR_NO_MODS);
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
// Create a table for the disclaimer.
|
// Create a table for the disclaimer.
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "Nach Spalte '{1}' kann nicht sortiert weden."
|
#define STRING_INVALID_SORT_COL "Nach Spalte '{1}' kann nicht sortiert weden."
|
||||||
#define STRING_TLS_INIT_FAIL "Fehler bei der TLS-Initialisierung. {1}"
|
#define STRING_TLS_INIT_FAIL "Fehler bei der TLS-Initialisierung. {1}"
|
||||||
#define STRING_ERROR_DETAILS "Die Option 'calendar.details.report' muss einen einzelnen Report-Namen enthalten."
|
#define STRING_ERROR_DETAILS "Die Option 'calendar.details.report' muss einen einzelnen Report-Namen enthalten."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
||||||
#define STRING_TLS_INIT_FAIL "Error initializing TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Error initializing TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "Kolumno '{1}' ne estas valida kampo por ordigi."
|
#define STRING_INVALID_SORT_COL "Kolumno '{1}' ne estas valida kampo por ordigi."
|
||||||
#define STRING_TLS_INIT_FAIL "Erara eko de TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Erara eko de TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "Agordo 'calendar.details.report' devas enhavi sole unu raportnomon."
|
#define STRING_ERROR_DETAILS "Agordo 'calendar.details.report' devas enhavi sole unu raportnomon."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -759,6 +759,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "La columna '{1}' no es un campo de ordenación válido."
|
#define STRING_INVALID_SORT_COL "La columna '{1}' no es un campo de ordenación válido."
|
||||||
#define STRING_TLS_INIT_FAIL "Error inicializando TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Error inicializando TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "El ajuste 'calendar.details.report' debe contener un único nombre de informe."
|
#define STRING_ERROR_DETAILS "El ajuste 'calendar.details.report' debe contener un único nombre de informe."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
||||||
#define STRING_TLS_INIT_FAIL "Erreur en initialisant TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Erreur en initialisant TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -746,6 +746,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "La colonna '{1}' non è un campo di ordinamento valido."
|
#define STRING_INVALID_SORT_COL "La colonna '{1}' non è un campo di ordinamento valido."
|
||||||
#define STRING_TLS_INIT_FAIL "Error initializing TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Error initializing TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
#define STRING_INVALID_SORT_COL "The '{1}' column is not a valid sort field."
|
||||||
#define STRING_TLS_INIT_FAIL "TLS初期化でエラー。 {1}"
|
#define STRING_TLS_INIT_FAIL "TLS初期化でエラー。 {1}"
|
||||||
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "Kolumna '{1}' nie jest poprawnym parametrem sortowania."
|
#define STRING_INVALID_SORT_COL "Kolumna '{1}' nie jest poprawnym parametrem sortowania."
|
||||||
#define STRING_TLS_INIT_FAIL "Błąd inicjalizacji TLS."
|
#define STRING_TLS_INIT_FAIL "Błąd inicjalizacji TLS."
|
||||||
#define STRING_ERROR_DETAILS "Zmienna 'calendar.details.report' musi zawierać nazwę raportu."
|
#define STRING_ERROR_DETAILS "Zmienna 'calendar.details.report' musi zawierać nazwę raportu."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
|
@ -747,6 +747,7 @@
|
||||||
#define STRING_INVALID_SORT_COL "A coluna '{1}' não pode ser ordenada."
|
#define STRING_INVALID_SORT_COL "A coluna '{1}' não pode ser ordenada."
|
||||||
#define STRING_TLS_INIT_FAIL "Erro a iniciar componente TLS. {1}"
|
#define STRING_TLS_INIT_FAIL "Erro a iniciar componente TLS. {1}"
|
||||||
#define STRING_ERROR_DETAILS "A definição 'calendar.details.report' pode apenas indicar um nome de relatório."
|
#define STRING_ERROR_DETAILS "A definição 'calendar.details.report' pode apenas indicar um nome de relatório."
|
||||||
|
#define STRING_ERROR_NO_FILTER "Command line filters are not support by this command."
|
||||||
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
#define STRING_ERROR_NO_MODS "Command line modifications are not support by this command."
|
||||||
|
|
||||||
// Feedback
|
// Feedback
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue