diff --git a/src/cli/index.ts b/src/cli/index.ts index e110746..cefcfdd 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -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 ", "sets the path to the YAML file with configuration") .option("-x, --set ", "overrides the config option for this specific run (arg: =, 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 ", "limits the current operation only to specified profile. If missing, all profiles will be affected") .parse() .opts(); @@ -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({ diff --git a/src/types/cli.ts b/src/types/cli.ts index 1967e8d..aef3e47 100644 --- a/src/types/cli.ts +++ b/src/types/cli.ts @@ -2,5 +2,7 @@ export type CLIOptions = { config: string; profile?: string; test: boolean; + scan: boolean; + notify: boolean; set: string[]; }; \ No newline at end of file