Skip to content

Latest commit

ย 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

fina โ€” Swift-Native CLI for Firefly III

A fast, type-safe command-line client for Firefly III, built with Swift 6 and swift-argument-parser. Manage accounts and transactions without leaving your terminal. ๐Ÿš€

โœจ Features

Feature Description
๐Ÿฆ accounts list List accounts with balances in an aligned table
๐Ÿงพ transactions list List transactions with --limit and --account filters
โž• transactions create Create a single-split transaction (withdrawal / deposit / transfer)
โœ๏ธ transactions update Update a single-split transaction by ID
โš™๏ธ Flexible config JSON config file with environment-variable fallback
๐Ÿ”’ Secure by default Config file permissions hardened to 0600 on load
๐Ÿงช Tested Unit tests with fixture-backed networking mocks

๐Ÿ“‹ Requirements

Requirement Version / Detail
๐ŸŽ Swift 6.3.3 (see .swift-version)
๐Ÿ“ฆ SwiftPM Bundled with the Swift toolchain
๐ŸŒ Firefly III Running instance with API access (/api/v1)
๐Ÿ”‘ API token Personal access token from Firefly III (Profile โ†’ OAuth)
๐Ÿ’ป Platform macOS or Linux

๐Ÿ“ฆ Installation

1๏ธโƒฃ Clone the repository

git clone https://github.com/mknnjp/fina-cli.git
cd fina-cli

2๏ธโƒฃ Build the release binary

swift build -c release

3๏ธโƒฃ Install to your PATH (optional)

cp .build/release/fina /usr/local/bin/fina
fina --help

๐Ÿ’ก Tip: during development, run directly with swift run fina -- <args>.

โš™๏ธ Configuration

fina resolves credentials in the following priority order:

Priority Source Detail
๐Ÿฅ‡ 1st ๐Ÿ“„ Config file ~/.config/fina/config.json (values take precedence)
๐Ÿฅˆ 2nd ๐ŸŒฟ Environment FINA_BASE_URL and FINA_TOKEN fill gaps / act as fallback

๐Ÿ“„ Option A โ€” Config file

{
  "baseURL": "https://firefly.example.com",
  "token": "your-personal-access-token"
}
mkdir -p ~/.config/fina
cat > ~/.config/fina/config.json <<'JSON'
{
  "baseURL": "https://firefly.example.com",
  "token": "your-personal-access-token"
}
JSON
chmod 600 ~/.config/fina/config.json

๐Ÿ”’ File permissions are automatically tightened to 0600 on successful load. base_url (snake_case) is also accepted as a key.

๐ŸŒฟ Option B โ€” Environment variables

Variable Description Example
FINA_BASE_URL Base URL of the Firefly III instance https://firefly.example.com
FINA_TOKEN Personal access token eyJ0eXAiOiJKV1QiLCJhbGci...
export FINA_BASE_URL="https://firefly.example.com"
export FINA_TOKEN="your-personal-access-token"

๐Ÿ–ฅ๏ธ Usage

fina --help
fina accounts --help
fina transactions --help

๐Ÿ“š Command reference

Command Purpose Key options
๐Ÿฆ fina accounts list List accounts with balances โ€”
๐Ÿงพ fina transactions list List transactions --limit <n>, --account <id-or-name>
โž• fina transactions create Create a single-split transaction --type, --date, --amount, --description, --source, --destination, --currency
โœ๏ธ fina transactions update <id> Update a single-split transaction --journal-id, --type, --date, --amount, --description, --source, --destination, --currency

๐Ÿฆ List accounts

fina accounts list

Example output:

ID  NAME            TYPE     CURRENCY  BALANCE
1   Main Checking   asset    JPY       125000
2   Cash Wallet     asset    JPY       12000

๐Ÿงพ List transactions

fina transactions list --limit 10
fina transactions list --account "Main Checking"
fina transactions list --limit 20 --account 1

Example output:

ID  DATE        DESCRIPTION      TYPE        AMOUNT  SOURCE         DESTINATION
12  2026-09-01  Grocery run      withdrawal  5400    Main Checking  Supermarket
13  2026-09-02  Salary           deposit     300000  Employer       Main Checking
Option Required Description
--limit <n> No Maximum number of transactions
--account <id-or-name> No Filter by account ID or name

โž• Create a transaction

fina transactions create \
  --type withdrawal \
  --date 2026-09-11 \
  --amount 1500 \
  --description "Coffee beans" \
  --source "Main Checking" \
  --destination "Cafe" \
  --currency JPY
Option Required Description
--type โœ… Yes withdrawal, deposit, or transfer
--date โœ… Yes YYYY-MM-DD
--amount โœ… Yes Decimal amount as a string (e.g. 1500)
--description โœ… Yes Human-readable description
--source โœ… Yes Source account ID or name
--destination โœ… Yes Destination account ID or name
--currency No Currency code (e.g. JPY, USD)

โœ๏ธ Update a transaction

fina transactions update 12 --amount 1600 --description "Coffee beans (updated)"
fina transactions update 12 --journal-id 45 --date 2026-09-10 --currency JPY
Option Required Description
<id> โœ… Yes Transaction ID (positional argument)
--journal-id No Transaction journal ID
--type / --date / --amount / --description No Fields to update
--source / --destination / --currency No Account / currency overrides

๐Ÿ“ค Output formats

Format Status Description
๐Ÿ“ plain โœ… Default Fixed-width aligned tables for humans
๐Ÿงฉ json ๐Ÿšง Reserved JSONFormatter seam exists; commands currently emit plain

๐Ÿ—๏ธ Project structure

Path Description
Sources/fina/ Executable entry point (@main)
Sources/FinaCore/Commands/ accounts and transactions subcommands
Sources/FinaCore/Commands/Shared/ Shared CommandContext and ClientFactory wiring
Sources/FinaCore/Config/ FinaConfig, ConfigLoader, ConfigError
Sources/FinaCore/Models/ Account, Transaction, Budget, API envelopes
Sources/FinaCore/Networking/ FireflyClient, FireflyAPI, error mapping
Sources/FinaCore/Output/ Plain-table and JSON formatters
Tests/finaTests/ Unit tests + JSON fixtures

๐Ÿงช Development

Task Command
๐Ÿ”จ Build swift build
โ–ถ๏ธ Run swift run fina -- accounts list
โœ… Test swift test
๐Ÿงน Format check swiftformat --lint . (if installed)

โš ๏ธ Error handling

Situation Behavior
๐Ÿ“ญ Missing config Clear error with expected path and required fields (baseURL, token)
๐Ÿงจ Invalid JSON / bad URL ConfigError.invalid with reason
๐ŸŒ HTTP 4xx / 5xx FireflyError.requestFailed with status code and body message
๐Ÿงฉ Decoding failure FireflyError.decodingFailed with detail

๐Ÿ—บ๏ธ Roadmap

Status Item
โœ… Done Accounts list, transactions list / create / update
๐Ÿšง Next --format json wiring, budgets commands
๐Ÿ”ฎ Later Pagination, search filters, interactive setup (fina init)

๐Ÿค Contributing

  1. ๐Ÿด Fork the repository.
  2. ๐ŸŒฑ Create a branch (e.g. feature/add-budgets-list).
  3. ๐Ÿ’พ Commit with Conventional Commits (e.g. feat(budgets): add budgets list command).
  4. ๐Ÿ“ฌ Open a pull request.

See .github/instructions/ for branch and commit conventions.

๐Ÿ“„ License

BSD 3-Clause License. See LICENSE for details. ยฉ 2026 mknnjp.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages