From bd7f3d50150efc62805bae2fd510a442bb61908e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 Jul 2016 08:55:18 -0400 Subject: [PATCH] CmdX: Added error message when expected ids are missing --- src/commands/CmdJoin.cpp | 2 +- src/commands/CmdLengthen.cpp | 3 +++ src/commands/CmdMove.cpp | 3 +++ src/commands/CmdShorten.cpp | 3 +++ src/commands/CmdSplit.cpp | 3 +++ src/commands/CmdTag.cpp | 3 +++ src/commands/CmdUntag.cpp | 3 +++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdJoin.cpp b/src/commands/CmdJoin.cpp index 8fc8a6f2..15703995 100644 --- a/src/commands/CmdJoin.cpp +++ b/src/commands/CmdJoin.cpp @@ -87,7 +87,7 @@ int CmdJoin ( } } else - std::cout << "Provide two interval IDs to join them.\n"; + throw std::string ("Two IDs must be specified. See 'timew help join'."); return 0; } diff --git a/src/commands/CmdLengthen.cpp b/src/commands/CmdLengthen.cpp index 7dc02b03..0fba41f2 100644 --- a/src/commands/CmdLengthen.cpp +++ b/src/commands/CmdLengthen.cpp @@ -50,6 +50,9 @@ int CmdLengthen ( delta = arg.attribute ("raw"); } + if (! ids.size ()) + throw std::string ("IDs must be specified. See 'timew help lengthen'."); + // TODO Support :adjust // Load the data. diff --git a/src/commands/CmdMove.cpp b/src/commands/CmdMove.cpp index 406fc121..d5be8e85 100644 --- a/src/commands/CmdMove.cpp +++ b/src/commands/CmdMove.cpp @@ -55,6 +55,9 @@ int CmdMove ( new_start = arg.attribute ("raw"); } + if (! id) + throw std::string ("ID must be specified. See 'timew help move'."); + // TODO Support :adjust // Load the data. diff --git a/src/commands/CmdShorten.cpp b/src/commands/CmdShorten.cpp index d62f48fd..bba0a265 100644 --- a/src/commands/CmdShorten.cpp +++ b/src/commands/CmdShorten.cpp @@ -50,6 +50,9 @@ int CmdShorten ( delta = arg.attribute ("raw"); } + if (! ids.size ()) + throw std::string ("IDs must be specified. See 'timew help shorten'."); + // TODO Support :adjust // Load the data. diff --git a/src/commands/CmdSplit.cpp b/src/commands/CmdSplit.cpp index 03a5a9db..1aa315d5 100644 --- a/src/commands/CmdSplit.cpp +++ b/src/commands/CmdSplit.cpp @@ -50,6 +50,9 @@ int CmdSplit ( delta = arg.attribute ("raw"); } + if (! ids.size ()) + throw std::string ("IDs must be specified. See 'timew help split'."); + // TODO Support :adjust // Load the data. diff --git a/src/commands/CmdTag.cpp b/src/commands/CmdTag.cpp index 836e5a14..64509105 100644 --- a/src/commands/CmdTag.cpp +++ b/src/commands/CmdTag.cpp @@ -48,6 +48,9 @@ int CmdTag ( tags.push_back (arg.attribute ("raw")); } + if (! ids.size ()) + throw std::string ("IDs must be specified. See 'timew help tag'."); + // Load the data. // Note: There is no filter. Interval filter; diff --git a/src/commands/CmdUntag.cpp b/src/commands/CmdUntag.cpp index efd78278..8b637c54 100644 --- a/src/commands/CmdUntag.cpp +++ b/src/commands/CmdUntag.cpp @@ -48,6 +48,9 @@ int CmdUntag ( tags.push_back (arg.attribute ("raw")); } + if (! ids.size ()) + throw std::string ("IDs must be specified. See 'timew help untag'."); + // Load the data. // Note: There is no filter. Interval filter;