Restore some CLI options

This commit is contained in:
2025-06-04 18:54:17 +02:00
parent 42d8f0db8b
commit 421a941262
2 changed files with 19 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import { loadConfig } from "../config";
import { notify, scan, test } from "../runner";
import { CronJob } from "cron";
import { startServer } from "../server";
import { Config } from "../types/config";
const getOptions = () => program
.name("obsidian-tasks-reminder")
@@ -12,6 +13,8 @@ const getOptions = () => program
.requiredOption("-c, --config <file>", "sets the path to the YAML file with configuration")
.option("-x, --set <arg>", "overrides the config option for this specific run (arg: <key>=<name>, i.e. backend.ntfy.enable=false", (v: string, prev: string[]) => prev.concat([v]), [])
.option("-t, --test", "evaluates the query, applies the mapper and prints to stdout the notifications about to be trigger, without actual triggering them")
.option("-s, --scan", "scans new tasks for future notifications and generates the database and exits immediately")
.option("-n, --notify", "reads the generated database and triggers notifications if any and exits immediately")
.option("-p, --profile <name>", "limits the current operation only to specified profile. If missing, all profiles will be affected")
.parse()
.opts<CLIOptions>();
@@ -44,6 +47,20 @@ const getOptions = () => program
return;
}
if (options.scan) {
await scan(config, options.profile);
return;
}
if (options.notify) {
await notify(config, options.profile);
return;
}
await start(config, options);
}
async function start(config: Config, options: CLIOptions) {
await scan(config);
const scanJob = CronJob.from({

View File

@@ -2,5 +2,7 @@ export type CLIOptions = {
config: string;
profile?: string;
test: boolean;
scan: boolean;
notify: boolean;
set: string[];
};