diff --git a/src/cli/index.ts b/src/cli/index.ts index 699ccfc..29426ed 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -8,6 +8,7 @@ export function run(...args: string[]) { .name("actual-importer") .version("0.0.1") .requiredOption("-c, --config ", "sets the path to the YAML file with configuration") + .option("-d, --dry-run", "simulates the import by printing out what will be imported") .option("-p, --profile ", "sets the desired profile to invoke") .option("-s, --server ", "sets the desired server to upload transactions to") .option("-x, --set ", "overrides the config option for this specific run (arg: =, i.e. profiles.myprofile.parser=pl.ing", (v: string, prev: string[]) => prev.concat([v]), []) @@ -49,5 +50,5 @@ function handle(file: string, options: CLIOptions) { const profile = options.profile ?? config.defaultProfile ?? Object.keys(config.profiles)[0]; const server = options.server ?? config.defaultServer ?? Object.keys(config.servers)[0]; - loadTransactions(file, profile, server, config); + loadTransactions(file, profile, server, config, options.dryRun); } \ No newline at end of file diff --git a/src/runner/index.ts b/src/runner/index.ts index 0dc54ee..f762bc0 100644 --- a/src/runner/index.ts +++ b/src/runner/index.ts @@ -6,7 +6,7 @@ import { Actual } from "@/server"; import { Config } from "@/types/config"; -export function loadTransactions(file: string, profile: string, server: string, config: Config) { +export function loadTransactions(file: string, profile: string, server: string, config: Config, dryRun?: boolean) { const profileConfig = config.profiles[profile]; if (!profileConfig) { throw new Error(`Unknown profile: ${profile}`); @@ -19,7 +19,7 @@ export function loadTransactions(file: string, profile: string, server: string, const parser = createParser(profileConfig, serverConfig); - const actualServer = new Actual(serverConfig, false); + const actualServer = new Actual(serverConfig, dryRun); const skipped: string[] = []; const handleRow = async (data: string[]) => { diff --git a/src/types/cli.ts b/src/types/cli.ts index 51726aa..784cafe 100644 --- a/src/types/cli.ts +++ b/src/types/cli.ts @@ -1,5 +1,6 @@ export type CLIOptions = { config: string; + dryRun?: boolean; profile?: string; server?: string; set: string[];