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:
@@ -32,6 +32,7 @@
|
||||
#include <time.h>
|
||||
#include <RX.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -64,6 +65,12 @@ CmdDiagnostics::CmdDiagnostics ()
|
||||
// kind of questions we always have to ask whenever something is wrong.
|
||||
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;
|
||||
if (context.color ())
|
||||
bold = Color ("bold");
|
||||
|
||||
@@ -56,6 +56,9 @@ int CmdExport::execute (std::string& output)
|
||||
std::vector <Task> filtered;
|
||||
filter.subset (filtered, false);
|
||||
|
||||
if (filter.hasModifications ())
|
||||
throw std::string (STRING_ERROR_NO_MODS);
|
||||
|
||||
// Obey 'limit:N'.
|
||||
int rows = 0;
|
||||
int lines = 0;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <CmdHelp.h>
|
||||
#include <ViewText.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -48,6 +49,12 @@ CmdHelp::CmdHelp ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
view.width (context.getWidth ());
|
||||
view.add (Column::factory ("string.left", ""));
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <JSON.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -54,6 +55,10 @@ int CmdImport::execute (std::string& output)
|
||||
int rc = 0;
|
||||
int count = 0;
|
||||
|
||||
Filter filter;
|
||||
if (filter.hasFilter ())
|
||||
throw std::string (STRING_ERROR_NO_FILTER);
|
||||
|
||||
// Get filenames from command line arguments.
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
if (! words.size () || (words.size () == 1 && words[0] == "-"))
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <cmake.h>
|
||||
#include <CmdLogo.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
@@ -50,6 +51,12 @@ CmdLogo::CmdLogo ()
|
||||
// extension.<uuid>=<JSON>
|
||||
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[] =
|
||||
{
|
||||
".........ABDEF",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
@@ -48,6 +49,12 @@ CmdReports::CmdReports ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
|
||||
// Add custom reports.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -54,6 +55,10 @@ int CmdSync::execute (std::string& output)
|
||||
#ifdef HAVE_LIBGNUTLS
|
||||
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.
|
||||
bool first_time_init = false;
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <Date.h>
|
||||
#include <main.h>
|
||||
|
||||
@@ -71,6 +71,11 @@ int CmdUDAs::execute (std::string& output)
|
||||
std::vector <Task> 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 ())
|
||||
{
|
||||
std::sort (udas.begin (), udas.end ());
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <cmake.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdUndo.h>
|
||||
|
||||
@@ -44,6 +45,12 @@ CmdUndo::CmdUndo ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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.
|
||||
if (context.cli2.getWords ().size ())
|
||||
throw std::string (STRING_CMD_UNDO_MODS);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#ifdef HAVE_COMMIT
|
||||
#include <commit.h>
|
||||
@@ -51,6 +52,12 @@ CmdVersion::CmdVersion ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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;
|
||||
|
||||
// Create a table for the disclaimer.
|
||||
|
||||
Reference in New Issue
Block a user