From d8a4b8ff4382208a56f6da9244cd800c63963a3d Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Sun, 15 Jul 2018 23:24:21 +0200 Subject: [PATCH] #9 TI-1 Add a skeleton undo command --- src/commands/CMakeLists.txt | 1 + src/commands/CmdUndo.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/commands/commands.h | 3 ++- src/init.cpp | 4 +++- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/commands/CmdUndo.cpp diff --git a/src/commands/CMakeLists.txt b/src/commands/CMakeLists.txt index a9959bdc..d43b72bf 100644 --- a/src/commands/CMakeLists.txt +++ b/src/commands/CMakeLists.txt @@ -32,6 +32,7 @@ set (commands_SRCS CmdCancel.cpp CmdTag.cpp CmdTags.cpp CmdTrack.cpp + CmdUndo.cpp CmdUntag.cpp) add_library (commands STATIC ${commands_SRCS}) diff --git a/src/commands/CmdUndo.cpp b/src/commands/CmdUndo.cpp new file mode 100644 index 00000000..76ceae96 --- /dev/null +++ b/src/commands/CmdUndo.cpp @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// https://www.opensource.org/licenses/mit-license.php +// +//////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +int CmdUndo (Database& database) +{ + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/commands.h b/src/commands/commands.h index 8a6a5bdf..293ada75 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez. +// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -58,6 +58,7 @@ int CmdStop (const CLI&, Rules&, Database& ); int CmdTag (const CLI&, Rules&, Database& ); int CmdTags (const CLI&, Rules&, Database& ); int CmdTrack (const CLI&, Rules&, Database& ); +int CmdUndo ( Database& ); int CmdUntag (const CLI&, Rules&, Database& ); int CmdChartDay (const CLI&, Rules&, Database& ); diff --git a/src/init.cpp b/src/init.cpp index d67ceef5..eceb5f01 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez. +// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -74,6 +74,7 @@ void initializeEntities (CLI& cli) cli.entity ("command", "tag"); cli.entity ("command", "tags"); cli.entity ("command", "track"); + cli.entity ("command", "undo"); cli.entity ("command", "untag"); // Some command list themselves as extensions, to integrate with the real @@ -284,6 +285,7 @@ int dispatchCommand ( else if (command == "tag") status = CmdTag (cli, rules, database ); else if (command == "tags") status = CmdTags (cli, rules, database ); else if (command == "track") status = CmdTrack (cli, rules, database ); + else if (command == "undo") status = CmdUndo ( database ); else if (command == "untag") status = CmdUntag (cli, rules, database ); else if (command == "week") status = CmdChartWeek (cli, rules, database ); else status = CmdReport (cli, rules, database, extensions);