mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-23 14:58:57 -05:00
- Flatten nested objects in table/csv output instead of showing [object Object] - Make --start/--end optional on transactions list (defaults to last 30 days) - Resolve payee, category, and account names in transactions list output via AQL - Add --exclude-transfers flag to transactions list and query run - Add query describe command for full schema output in one call - Add select shorthand aliases (payee → payee.name, category → category.name) - Add field descriptions to query fields/describe output (e.g. amount is in cents) - Add CliError class with suggestion messages for better error guidance https://claude.ai/code/session_01Tzo7tE4YutV9hqgHNYonXB
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
export function defaultDateRange(
|
|
start?: string,
|
|
end?: string,
|
|
): { start: string; end: string } {
|
|
const endDate = end ?? new Date().toLocaleDateString('en-CA');
|
|
if (start) return { start, end: endDate };
|
|
const d = new Date(endDate + 'T00:00:00');
|
|
d.setDate(d.getDate() - 30);
|
|
return { start: d.toLocaleDateString('en-CA'), end: endDate };
|
|
}
|
|
|
|
export class CliError extends Error {
|
|
suggestion?: string;
|
|
constructor(message: string, suggestion?: string) {
|
|
super(message);
|
|
this.suggestion = suggestion;
|
|
}
|
|
}
|
|
|
|
export function parseBoolFlag(value: string, flagName: string): boolean {
|
|
if (value !== 'true' && value !== 'false') {
|
|
throw new Error(
|
|
`Invalid ${flagName}: "${value}". Expected "true" or "false".`,
|
|
);
|
|
}
|
|
return value === 'true';
|
|
}
|
|
|
|
export function parseIntFlag(value: string, flagName: string): number {
|
|
const parsed = value.trim() === '' ? NaN : Number(value);
|
|
if (!Number.isInteger(parsed)) {
|
|
throw new Error(`Invalid ${flagName}: "${value}". Expected an integer.`);
|
|
}
|
|
return parsed;
|
|
}
|