34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import type { CorpConfig } from "../../core/config/types.js";
|
|
import type { createSealClient } from "../../core/http/factory.js";
|
|
import { runTool } from "../helpers.js";
|
|
import { numberOption, stringOption } from "../parser.js";
|
|
import { outputOptions } from "../printer.js";
|
|
import type { ParsedArgs } from "../types.js";
|
|
|
|
export async function handleDataCommand(
|
|
action: string | undefined,
|
|
client: Awaited<ReturnType<typeof createSealClient>>,
|
|
corp: CorpConfig,
|
|
args: ParsedArgs
|
|
) {
|
|
const params = {
|
|
offset: numberOption(args.options.offset),
|
|
limit: numberOption(args.options.limit),
|
|
startDate: stringOption(args.options.startDate) ?? stringOption(args.options["start-date"]),
|
|
endDate: stringOption(args.options.endDate) ?? stringOption(args.options["end-date"]),
|
|
search: stringOption(args.options.search) ?? stringOption(args.options.query)
|
|
};
|
|
|
|
if (action === "expenses" || action === "expense") {
|
|
await runTool("seal_expenses_list", client, corp, params, outputOptions(args.options));
|
|
return;
|
|
}
|
|
|
|
if (action === "invoices" || action === "invoice") {
|
|
await runTool("seal_invoices_list", client, corp, params, outputOptions(args.options));
|
|
return;
|
|
}
|
|
|
|
throw new Error(`Unknown data command: ${action ?? ""}. Run 'seal-use help' for available commands.`);
|
|
}
|