From ae5319c58cd6b42e42965d687e0722f55952d3fb Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Fri, 17 Dec 2021 17:00:22 +0100 Subject: [PATCH] version command added --- README.md | 5 ++++- src/tt.h | 2 ++ src/ui.cpp | 12 +++++++++++- src/ui.h | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 954cc9b..777bd3c 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Switched to task HPCE/test ~~~ #### `rm [/] | ` -Deletes all data of a project or task. \ +Deletes all data of a project or task.\ If only a project name is provided, the project with all tasks is beeing deleted. The previous project in the project list is set active\ If only a task name is provided, this task is beeing deleted from the active project if present. The previous task in the task list is set active.\ If `/` is provided, the task with name `` is deleted from project `` if both are present. @@ -250,3 +250,6 @@ Project: Code Project --- Debugging: 9.26 Total: 24.35 ~~~ + +### `version` +Prints the version number of `tt` diff --git a/src/tt.h b/src/tt.h index 0ab361c..4633dc3 100644 --- a/src/tt.h +++ b/src/tt.h @@ -3,6 +3,8 @@ #include +#define TT_VERSION 1.0 + // global variables: extern std::string user_name; extern std::string tracking_dir; diff --git a/src/ui.cpp b/src/ui.cpp index 278fcab..88c26c0 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -28,7 +28,8 @@ std::string command_names[num_commands]={ "report", "ls", "start", - "save" + "save", + "version" }; std::vector autocomplete_names; // global variable @@ -173,6 +174,8 @@ void parse_input(std::string input, ProjectList *proj_list){ } }else if (command == "save"){ command_save(proj_list); + }else if (command == "version"){ + command_version(); } } @@ -612,3 +615,10 @@ void command_save(ProjectList *proj_list){ proj_list->save(file_name); std::cout << "Tracking data saved to file " << file_name << std::endl; } + +// print version number +void command_version(){ + std::cout << "tt v." << STRING(TT_VERSION) << std::endl; + std::cout << "Author: Patrick Lipka (patrick.lipka@emea.nec.com)" << std::endl; + std::cout << "tt is free software published under the BSD-2-Clause licence (see. https://opensource.org/licenses/BSD-2-Clause)" << std::endl; +} diff --git a/src/ui.h b/src/ui.h index a000d14..5fde932 100644 --- a/src/ui.h +++ b/src/ui.h @@ -5,7 +5,7 @@ #include #include "project.h" -const int num_commands=12; +const int num_commands=13; extern std::string command_names[num_commands]; extern std::vector autocomplete_names; char **tt_name_completion(const char* text, int start, int end); @@ -30,4 +30,5 @@ void command_at(std::string input, int wtime, ProjectList *proj_list); void command_rt(std::string input, int wtime, ProjectList *proj_list); void command_report(std::string date_str, ProjectList *proj_list); void command_save(ProjectList *proj_list); +void command_version(); #endif