Added bold output in report

This commit is contained in:
Patrick Lipka 2022-04-05 15:04:22 +02:00
parent 3a3a184b5e
commit 3436069b7c
5 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,7 @@
-include config.out -include config.out
CXX ?= g++ CXX ?= g++
CPPFLAGS ?= -DFORMATTED_TEXT
CXXFLAGS := -std=c++11 -g -Wall -pedantic CXXFLAGS := -std=c++11 -g -Wall -pedantic
OBJFLAGS := $(CXXFLAGS) -c OBJFLAGS := $(CXXFLAGS) -c
LDFLAGS := -lreadline LDFLAGS := -lreadline
@ -21,7 +22,7 @@ $(BIN_PATH)/tt: $(OBJ)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(CXX) $(CXXFLAGS) -o $@ $(OBJ) $(LDFLAGS)
$(SRC_PATH)/%.o: $(SRC_PATH)/%.cpp $(SRC_PATH)/%.o: $(SRC_PATH)/%.cpp
$(CXX) -DPREFIX=$(PREFIX) $(OBJFLAGS) -o $@ $< $(CXX) -DPREFIX=$(PREFIX) $(CPPFLAGS) $(OBJFLAGS) -o $@ $<
makedir: makedir:
@mkdir -p $(BIN_PATH) @mkdir -p $(BIN_PATH)

View File

@ -26,6 +26,7 @@ The following variables can be used to configure the build:
* `PREFIX` - install prefix, defaults to `/usr/local` * `PREFIX` - install prefix, defaults to `/usr/local`
* `USER_NAME` - user name to be mentioned in monthly reports, defaults to `$USER` * `USER_NAME` - user name to be mentioned in monthly reports, defaults to `$USER`
* `TRACKING_DIR` - directory where tracking files are saved, defaults to `$HOME/track` * `TRACKING_DIR` - directory where tracking files are saved, defaults to `$HOME/track`
* `CPPFLAGS` - set to `-UFORMATTED_TEXT` if your terminal does not support usual Unix escape sequences
The user name and tracking directory can also be set after installation by modifying `$PREFIX/etc/tt.conf` The user name and tracking directory can also be set after installation by modifying `$PREFIX/etc/tt.conf`

View File

@ -3,7 +3,7 @@
#include <string> #include <string>
#define TT_VERSION 1.2.0 #define TT_VERSION 1.2.0_dev
#define TT_IO_VERSION 120 #define TT_IO_VERSION 120
// global variables: // global variables:

View File

@ -591,13 +591,13 @@ void command_report(std::string date_str, ProjectList* proj_list){
Project *proj = &(proj_list->projects[i]); Project *proj = &(proj_list->projects[i]);
float wtime_proj = proj->get_total_work_time() / 3600.0; float wtime_proj = proj->get_total_work_time() / 3600.0;
if(wtime_proj >= 0.01){ if(wtime_proj >= 0.01){
std::cout << "Project: " << proj->name << std::endl; std::cout << "Project: " << TERM_BOLD << proj->name << TERM_RESET << std::endl;
for(int j=0; j<proj->num_tasks; j++){ for(int j=0; j<proj->num_tasks; j++){
float wtime_task = proj->tasks[j].work_time / 3600.0; float wtime_task = proj->tasks[j].work_time / 3600.0;
if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl; if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl;
} }
// format: *.xx hours // format: *.xx hours
std::cout << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << std::endl << std::endl; std::cout << TERM_BOLD << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << TERM_RESET << std::endl << std::endl;
} }
} }
}else{ }else{
@ -611,13 +611,13 @@ void command_report(std::string date_str, ProjectList* proj_list){
Project *proj = &(list.projects[i]); Project *proj = &(list.projects[i]);
float wtime_proj = proj->get_total_work_time() / 3600.0; float wtime_proj = proj->get_total_work_time() / 3600.0;
if(wtime_proj >= 0.01){ if(wtime_proj >= 0.01){
std::cout << "Project: " << proj->name << std::endl; std::cout << "Project: " << TERM_BOLD << proj->name << TERM_RESET << std::endl;
for(int j=0; j<proj->num_tasks; j++){ for(int j=0; j<proj->num_tasks; j++){
float wtime_task = proj->tasks[j].work_time / 3600.0; float wtime_task = proj->tasks[j].work_time / 3600.0;
if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl; if(wtime_task >= 0.01) std::cout << "--- " << proj->tasks[j].name << ": " << std::fixed << std::setprecision(2) << wtime_task << std::endl;
} }
// format: *.xx hours // format: *.xx hours
std::cout << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << std::endl << std::endl; std::cout << TERM_BOLD << "Total: " << std::fixed << std::setprecision(2) << wtime_proj << TERM_RESET << std::endl << std::endl;
} }
} }
}else{ }else{

View File

@ -1,6 +1,15 @@
#ifndef UI_H #ifndef UI_H
#define UI_H #define UI_H
// define terminal format codes
#ifdef FORMATTED_TEXT
#define TERM_BOLD "\033[1m"
#define TERM_RESET "\033[0m"
#else
#define TERM_BOLD ""
#define TERM_RESET ""
#endif
#include <vector> #include <vector>
#include <string> #include <string>
#include "project.h" #include "project.h"