mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-05-16 12:30:09 +02:00
Allow combining of a command-line datespec with a command-line trigger.
This commit is contained in:
@@ -551,6 +551,17 @@ the 13th, you could use this:
|
||||
remind .reminders '@13 SATISFY [$Tw == 5]'
|
||||
.fi
|
||||
.PP
|
||||
You can also specify the date directly \fIand\fR use an "@" trigger
|
||||
argument; in this case, Remind uses the specified date as the starting
|
||||
point for the trigger calculation. As an example:
|
||||
.PP
|
||||
.nf
|
||||
remind .reminders 2026-07-01 '@13 SATISFY [$Tw == 5]'
|
||||
.fi
|
||||
.PP
|
||||
will set \fBRemind\fR's notion of "today" to 2026-11-13 because that
|
||||
is the first Friday the 13th on or after 2026-07-01.
|
||||
.PP
|
||||
In addition, you can supply a \fIrepeat\fR parameter, which has the
|
||||
form *\fIrep\fR. This causes \fBRemind\fR to be run \fIrep\fR times,
|
||||
with the date incrementing on each iteration. You may have to enclose
|
||||
|
||||
+39
-31
@@ -55,6 +55,7 @@ static void tty_raw(int fd);
|
||||
static void tty_reset(int fd);
|
||||
|
||||
static int GetInitDateFromTrigger(char const *s, int *y, int *m, int *d, int *systime);
|
||||
static void SetTodayFromCmdlineArgs(int dse, int y, int m, int d);
|
||||
|
||||
static void ProcessLongOption(char const *arg);
|
||||
/***************************************************************
|
||||
@@ -745,11 +746,10 @@ void InitRemind(int argc, char const *argv[])
|
||||
arg = argv[i++];
|
||||
/* If it begins with '@' then it's a trigger spec */
|
||||
if (*arg == '@') {
|
||||
if (m != NO_MON || d != NO_DAY || y != NO_YR || dse != NO_DATE) {
|
||||
Usage();
|
||||
}
|
||||
SetTodayFromCmdlineArgs(dse, y, m, d);
|
||||
r = GetInitDateFromTrigger(arg+1, &y, &m, &d, &SysTime);
|
||||
if (r == OK) {
|
||||
dse = NO_DATE; /* Date is in y/m/d */
|
||||
if (SysTime != -1) {
|
||||
DontQueue = 1;
|
||||
Daemon = 0;
|
||||
@@ -825,34 +825,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
Daemon = 0;
|
||||
}
|
||||
|
||||
if (dse != NO_DATE) {
|
||||
FromDSE(dse, &y, &m, &d);
|
||||
}
|
||||
/* Must supply date in the form: day, mon, yr OR mon, yr */
|
||||
if (m != NO_MON || y != NO_YR || d != NO_DAY) {
|
||||
if (y == NO_YR) {
|
||||
y = CurYear;
|
||||
}
|
||||
if (m == NO_MON) {
|
||||
Usage();
|
||||
}
|
||||
if (d == NO_DAY) d=1;
|
||||
if (d > DaysInMonth(m, y)) {
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
DSEToday = DSE(y, m, d);
|
||||
if (DSEToday == -1) {
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
LocalDSEToday = DSEToday;
|
||||
CurYear = y;
|
||||
CurMon = m;
|
||||
CurDay = d;
|
||||
if (DSEToday != RealToday) IgnoreOnce = 1;
|
||||
}
|
||||
|
||||
SetTodayFromCmdlineArgs(dse, y, m, d);
|
||||
}
|
||||
|
||||
/* JSON mode turns off sorting */
|
||||
@@ -1479,7 +1452,42 @@ GetInitDateFromTrigger(char const *s, int *y, int *m, int *d, int *systime)
|
||||
*systime = tim.ttime * 60;
|
||||
}
|
||||
FromDSE(dse, y, m, d);
|
||||
if (dse != RealToday) {
|
||||
IgnoreOnce = 1;
|
||||
}
|
||||
}
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static void
|
||||
SetTodayFromCmdlineArgs(int dse, int y, int m, int d)
|
||||
{
|
||||
if (dse != NO_DATE) {
|
||||
FromDSE(dse, &y, &m, &d);
|
||||
}
|
||||
/* Must supply date in the form: day, mon, yr OR mon, yr */
|
||||
if (m != NO_MON || y != NO_YR || d != NO_DAY) {
|
||||
if (y == NO_YR) {
|
||||
y = CurYear;
|
||||
}
|
||||
if (m == NO_MON) {
|
||||
Usage();
|
||||
}
|
||||
if (d == NO_DAY) d=1;
|
||||
if (d > DaysInMonth(m, y)) {
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
DSEToday = DSE(y, m, d);
|
||||
if (DSEToday == -1) {
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
LocalDSEToday = DSEToday;
|
||||
CurYear = y;
|
||||
CurMon = m;
|
||||
CurDay = d;
|
||||
if (DSEToday != RealToday) IgnoreOnce = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,6 +1000,11 @@ echo "REM MSG %y-%t-%r" | $REMIND --test - '@January' >> $OUT 2>&1
|
||||
echo "REM MSG %y-%t-%r" | $REMIND --test - '@Dec SATISFY [$Tw == 6]' >> $OUT 2>&1
|
||||
echo "REM MSG %y-%t-%r" | $REMIND --test - '@Dec 1990' >> $OUT 2>&1
|
||||
|
||||
echo "REM MSG %y-%t-%r" | $REMIND - 2026-08-01 '@13 SATISFY [$Tw == 5]' >> $OUT 2>&1
|
||||
echo "REM MSG %y-%t-%r" | $REMIND - 2026-08-01 '@January' >> $OUT 2>&1
|
||||
echo "REM MSG %y-%t-%r" | $REMIND - 2026-08-01 '@Dec SATISFY [$Tw == 6]' >> $OUT 2>&1
|
||||
echo "REM MSG %y-%t-%r" | $REMIND - 2026-08-01 '@Dec 1990' >> $OUT 2>&1
|
||||
|
||||
cmp -s $OUT $CMP
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "Remind: Acceptance tests ${GRN}PASSED${NRM}"
|
||||
|
||||
@@ -40308,3 +40308,16 @@ Enabling test mode: This is meant for the acceptance test.
|
||||
Do not use --test in production.
|
||||
In test mode, the system time is fixed at 2025-01-06@19:00
|
||||
Could not evaluate command-line trigger: Can't compute trigger
|
||||
Reminders for Friday, 13th November, 2026:
|
||||
|
||||
2026-11-13
|
||||
|
||||
Reminders for Friday, 1st January, 2027:
|
||||
|
||||
2027-01-01
|
||||
|
||||
Reminders for Saturday, 5th December, 2026:
|
||||
|
||||
2026-12-05
|
||||
|
||||
Could not evaluate command-line trigger: Can't compute trigger
|
||||
|
||||
Reference in New Issue
Block a user