Restore some CLI options
This commit is contained in:
@@ -5,6 +5,7 @@ import { loadConfig } from "../config";
|
|||||||
import { notify, scan, test } from "../runner";
|
import { notify, scan, test } from "../runner";
|
||||||
import { CronJob } from "cron";
|
import { CronJob } from "cron";
|
||||||
import { startServer } from "../server";
|
import { startServer } from "../server";
|
||||||
|
import { Config } from "../types/config";
|
||||||
|
|
||||||
const getOptions = () => program
|
const getOptions = () => program
|
||||||
.name("obsidian-tasks-reminder")
|
.name("obsidian-tasks-reminder")
|
||||||
@@ -12,6 +13,8 @@ const getOptions = () => program
|
|||||||
.requiredOption("-c, --config <file>", "sets the path to the YAML file with configuration")
|
.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("-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("-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")
|
.option("-p, --profile <name>", "limits the current operation only to specified profile. If missing, all profiles will be affected")
|
||||||
.parse()
|
.parse()
|
||||||
.opts<CLIOptions>();
|
.opts<CLIOptions>();
|
||||||
@@ -44,6 +47,20 @@ const getOptions = () => program
|
|||||||
return;
|
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);
|
await scan(config);
|
||||||
|
|
||||||
const scanJob = CronJob.from({
|
const scanJob = CronJob.from({
|
||||||
|
|||||||
@@ -2,5 +2,7 @@ export type CLIOptions = {
|
|||||||
config: string;
|
config: string;
|
||||||
profile?: string;
|
profile?: string;
|
||||||
test: boolean;
|
test: boolean;
|
||||||
|
scan: boolean;
|
||||||
|
notify: boolean;
|
||||||
set: string[];
|
set: string[];
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user