feat: add ansi colors
This commit is contained in:
24
app.cpp
24
app.cpp
@@ -143,7 +143,7 @@ int gymTrackerStatus(Arena *arena, list<string> args) {
|
||||
GymLogDbParsed *db = parseDb(arena, os_readEntireFile(arena, DB_FILE_LOCATION));
|
||||
|
||||
Timestamp startTs = {0};
|
||||
ParsePositiveIntResult numDays = {1, false};
|
||||
ParsePositiveIntResult numDays = {1, true};
|
||||
bool showAll = args.length == 1 && strEql(args.data[0], "--all"_s);
|
||||
if (!showAll) {
|
||||
if (args.length == 2 && (strEql(args.data[0], "--days"_s) || strEql(args.data[0], "-d"_s))) {
|
||||
@@ -169,6 +169,7 @@ int gymTrackerStatus(Arena *arena, list<string> args) {
|
||||
list<string> nameByExercise = PushFullListZero(arena, string, db->header.nextId);
|
||||
|
||||
list<real32> workPerExerciseByDay = PushFullListZero(arena, real32, db->header.nextId);
|
||||
list<real32> workPerExerciseByPrevDay = PushFullListZero(arena, real32, db->header.nextId);
|
||||
list<uint32> restPerExerciseByDay = PushFullListZero(arena, uint32, db->header.nextId);
|
||||
list<uint32> lastTsPerExerciseByDay = PushFullListZero(arena, uint32, db->header.nextId);
|
||||
|
||||
@@ -192,7 +193,7 @@ int gymTrackerStatus(Arena *arena, list<string> args) {
|
||||
if (dayCount > 0) {
|
||||
log("\n");
|
||||
}
|
||||
log("================ %S =================================\n", formatTimeYmd(arena, ×tamp));
|
||||
log("================ %S ===================\n", formatTimeYmd(arena, ×tamp));
|
||||
lastDay = timestamp.tm_yday;
|
||||
lastYear = timestamp.tm_year;
|
||||
dayCount++;
|
||||
@@ -245,12 +246,29 @@ int gymTrackerStatus(Arena *arena, list<string> args) {
|
||||
log("Work summary:\n");
|
||||
for (size_t j = 0; j < workPerExerciseByDay.length; j++) {
|
||||
if (workPerExerciseByDay.data[j] != 0.0f) {
|
||||
log("%S: %.2fkg in %.2fmin\n", nameByExercise.data[j], workPerExerciseByDay.data[j], (real32)restPerExerciseByDay.data[j] / 60.0f);
|
||||
const char *fmtString;
|
||||
real32 improvement = 0;
|
||||
if (workPerExerciseByPrevDay.data[j] == 0) {
|
||||
fmtString = COLOR_TEXT("%S", ANSI_fg_cyan) ": %.2fkg in %.2fmin\n";
|
||||
} else {
|
||||
improvement = workPerExerciseByDay.data[j] - workPerExerciseByPrevDay.data[j];
|
||||
if (improvement > 0) {
|
||||
fmtString = COLOR_TEXT("%S", ANSI_fg_cyan) ": %.2fkg in %.2fmin " COLOR_TEXT("+%.2fkg\n", ANSI_fg_green);
|
||||
} else {
|
||||
fmtString = COLOR_TEXT("%S", ANSI_fg_cyan) ": %.2fkg in %.2fmin " COLOR_TEXT("%.2fkg\n", ANSI_fg_red);
|
||||
}
|
||||
}
|
||||
|
||||
log(fmtString, nameByExercise.data[j], workPerExerciseByDay.data[j], (real32)restPerExerciseByDay.data[j] / 60.0f, improvement);
|
||||
|
||||
workPerExerciseByPrevDay.data[j] = workPerExerciseByDay.data[j];
|
||||
}
|
||||
}
|
||||
zeroListFull(&workPerExerciseByDay);
|
||||
zeroListFull(&restPerExerciseByDay);
|
||||
zeroListFull(&lastTsPerExerciseByDay);
|
||||
prevEntry = 0;
|
||||
entry = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user