Exit prompt

Cause: any answer other than y was treated as no, so your t discarded the changes.
Fix: the prompt now only accepts y (save), n (discard) or c (cancel the exit). Anything else asks again, so a typo can't lose data. In my test, t, an empty line, then y saved correctly.
Also: I changed the db restore confirmation to y/n only, with no cancel option. Closing stdin still saves automatically.

Wait without a time

tsk restat <task> wait: works with no time while the task's account is still waiting, and the task just follows that wait. tsk add <task> <acc> wait works the same way.
Time required: otherwise it asks for one, with a message saying why. That covers an account that isn't waiting, an account whose wait is already over (Limit reset), and a task with no account.
acc wait: it still requires a time. A plain acc wait would have nothing to do, since the account already has a wait.

Account panel: there's a new RESET column showing when the account's wait ends. It shows 16:30 for today, tomorrow 06:40 for the next day, or a full date like 2020-01-01 10:00 (which is how an old, already-reset wait appears). Accounts with no wait show -. Since the time is in its own column now, an account with a wait but no task showing it lists just (wait) or (limit reset) in the TASKS column.
This commit is contained in:
alejo committed 2026-10-24 09:18:43 -03:00
1 parent 0af468f47c
commit 35c568333d
6 files changed
+153 -40

No files matched your search

+10 -2
View File
@@ -1,6 +1,8 @@
#pragma once
#include <cstddef>
#include <ctime>
#include <optional>
#include <string>
#include <vector>
@@ -40,12 +42,18 @@ private:
void setAccountWait(const std::string& account, std::time_t until);
void noteAccountWait(const std::string& taskName);
void flushMessages();
void endOfInput();
bool confirm(const std::string& question) const;
bool endOfInput(); // true if the program should exit
enum class Answer { Yes, No, Cancel };
// Asks until the reply is valid (y / n, and c when allowed). nullopt if input closed.
std::optional<Answer> ask(const std::string& question, bool allowCancel) const;
// Helpers
static void requireName(const std::string& name);
static Status parseStatusFrom(const Args& args, std::size_t from);
static bool isBareWait(const Args& args, std::size_t from);
std::optional<std::time_t> runningWait(const std::string& account) const;
void makeTaskFollowAccount(const TaskRow& task);
// Account commands
bool cmdAccAdd(const Args& args);
+2
View File
@@ -42,6 +42,8 @@ Status effective(const Status& status, std::time_t now);
std::string timeToText(std::time_t value);
std::optional<std::time_t> timeFromText(const std::string& text);
std::string clockLabel(std::time_t value); // "16:30"
// "16:30" for today, "tomorrow 06:40" for the next day, otherwise "2026-10-26 16:30".
std::string resetLabel(std::time_t value, std::time_t now);
std::string label(const Status& status); // "Prompt", "Limit reset", "Wait 16:30", ...
std::string kindName(StatusKind kind); // lowercase token: "prompt", "limit-reset", ...