Core library for building lunch-money-cli plugins: base command, config, formatters, and API client utilities.
npm install lunch-money-cli-coreAbstract base class extending oclif's Command with --json output, structured error handling, and an output() helper. Use this for commands that don't need API access (e.g. auth).
import { BaseCommand } from "lunch-money-cli-core";
export default class Auth extends BaseCommand {
async run() {
// has this.output(), --json, and error handling
return this.output({ success: true }, "Done.");
}
}Extends BaseCommand with a global --api-key flag and createClient(). Commands parse their own flags and pass flags["api-key"] to createClient(), which falls back to the LUNCH_MONEY_API_KEY env var, then the saved config file.
import { ApiCommand } from "lunch-money-cli-core";
export default class MyCommand extends ApiCommand {
async run() {
const { flags } = await this.parse(MyCommand);
const client = this.createClient(flags["api-key"]);
const data = await client.getTransactions();
return this.output(data, formatTable(data, transactionColumns));
}
}Creates a LunchMoneyClient instance from an API key.
import { createClient } from "lunch-money-cli-core";
const client = createClient("your-api-key");Argument parsing utilities for CLI commands.
import { parseIntArg, parseJsonArg } from "lunch-money-cli-core";
const id = parseIntArg("123", "id"); // 123
const body = parseJsonArg('{"name": "Test"}', "body"); // { name: "Test" }File-based configuration management.
import { loadConfig, saveConfig, getConfigPath } from "lunch-money-cli-core";
const config = loadConfig(configDir);
saveConfig(configDir, { api_key: "your-key" });Terminal-aware table and detail formatting.
import { formatTable, formatDetail, formatMessage } from "lunch-money-cli-core";
import type { ColumnDef, FieldDef } from "lunch-money-cli-core";
const table = formatTable(rows, columns);
const detail = formatDetail(data, fields);Predefined column/field definitions for all Lunch Money data types:
accountColumns/accountFieldscategoryColumns/categoryFieldstagColumns/tagFieldstransactionColumns/transactionFieldsplaidAccountColumns/plaidAccountFieldsrecurringColumns/recurringFieldssummaryColumnsuserFields/budgetSettingsFields
MIT