{"id":48856714,"url":"https://github.com/stargately/beancount-cli","last_synced_at":"2026-04-20T04:07:27.171Z","repository":{"id":350989998,"uuid":"1209073850","full_name":"stargately/beancount-cli","owner":"stargately","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-15T11:18:05.000Z","size":4703,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-15T13:03:47.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stargately.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-13T04:18:15.000Z","updated_at":"2026-04-15T11:18:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stargately/beancount-cli","commit_stats":null,"previous_names":["stargately/beancount-cli"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/stargately/beancount-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stargately%2Fbeancount-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stargately%2Fbeancount-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stargately%2Fbeancount-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stargately%2Fbeancount-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stargately","download_url":"https://codeload.github.com/stargately/beancount-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stargately%2Fbeancount-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32032310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-15T13:00:38.117Z","updated_at":"2026-04-20T04:07:27.132Z","avatar_url":"https://github.com/stargately.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# beancount-cli\n\nA Go command-line tool for [Beancount](https://beancount.io). It authenticates via a browser-based device authorization flow and communicates with the Beancount GraphQL backend.\n\n## Commands\n\nSee [docs/commands.md](docs/commands.md) for the full command reference including flags and examples.\n\n## Installation\n\n**Homebrew (macOS / Linux):**\n\n```sh\nbrew tap stargately/beancount-cli\nbrew install beancount-cli\n```\n\n**Install script (macOS / Linux):**\n\n```sh\ncurl -sf https://raw.githubusercontent.com/stargately/beancount-cli/main/scripts/install.sh | sh\n```\n\nInstall a specific version or to a custom directory:\n\n```sh\n# Specific version\ncurl -sf https://raw.githubusercontent.com/stargately/beancount-cli/main/scripts/install.sh | VERSION=v0.1.0 sh\n\n# Custom install directory\ncurl -sf https://raw.githubusercontent.com/stargately/beancount-cli/main/scripts/install.sh | BINDIR=$HOME/.local/bin sh\n```\n\nInstalls to `/usr/local/bin` by default (uses `sudo` if needed). Requires `curl` and `tar`.\n\n**From source** (requires Go 1.23+):\n\n```sh\nmake build\n\n# Binary is output to ./dist/beancount-cli\n./dist/beancount-cli --help\n\n# Optional: move to PATH\ncp dist/beancount-cli /usr/local/bin/beancount-cli\n```\n\n## Environment Variables\n\n| Variable                 | Default                              | Description                             |\n|--------------------------|--------------------------------------|-----------------------------------------|\n| `BEANCOUNT_API_URL`      | `https://beancount.io/api-gateway/`  | GraphQL API endpoint                    |\n| `BEANCOUNT_DASHBOARD_URL`| `https://beancount.io`               | Dashboard URL (used for the auth flow)  |\n\n## Connecting to a Local Dev Server\n\nTo test against your local development environment, start both the backend and dashboard, then point the CLI at them via environment variables.\n\n**1. Start the backend** (GraphQL API on port 4104):\n\n```sh\ncd backend-cluster/backend-v2\nyarn start\n```\n\n**2. Start the dashboard** (required for the browser-based login flow, port 5173):\n\n```sh\ncd beancount-dashboard\nyarn dev\n```\n\n**3. Configure the CLI and log in:**\n\n```sh\nexport BEANCOUNT_API_URL=http://localhost:4104/\nexport BEANCOUNT_DASHBOARD_URL=http://localhost:5173\n\n./dist/beancount-cli login\n```\n\nThe `login` command will open `http://localhost:5173/auth/login/device?session_id=...` in your browser. Approve the session there and the CLI will save a token to `~/.beancount/credentials.json`.\n\n## Credentials\n\nCredentials are stored locally at `~/.beancount/credentials.json` (permissions `0600`):\n\n```json\n{\n  \"token\": \"\u003cjwt\u003e\",\n  \"expireAt\": \"2026-12-31T00:00:00Z\"\n}\n```\n\nRun `beancount-cli logout` to revoke the token and delete this file.\n\n## Release\n\nReleases are automated via GoReleaser. The GitHub Actions workflow (`.github/workflows/release.yml`) triggers on `v*` tag pushes and handles everything end-to-end. For local use, you need [GoReleaser](https://goreleaser.com/install/) and the [GitHub CLI](https://cli.github.com/) installed and authenticated (`gh auth login`).\n\n### 1. Build artifacts only (no publish)\n\nBuilds all platform binaries and archives into `./dist/` without publishing anything. Does not require a git tag.\n\n```sh\ngoreleaser release --clean --snapshot\n```\n\n### 2. Build and publish to GitHub Release only\n\n```sh\ngit tag v0.1.0\ngit push origin v0.1.0\nGITHUB_TOKEN=$(gh auth token) goreleaser release --clean --skip=homebrew\n```\n\n### 3. Full release (GitHub + Homebrew)\n\n```sh\ngit tag v0.1.0\ngit push origin v0.1.0\nGITHUB_TOKEN=$(gh auth token) TAP_GITHUB_TOKEN=$(gh auth token) goreleaser release --clean\n```\n\n---\n\n## Development\n\n### Make Targets\n\n| Target          | Description                                                      |\n|-----------------|------------------------------------------------------------------|\n| `make build`    | Compile binary to `./dist/beancount-cli`                         |\n| `make lint`     | Run `go vet ./...`                                               |\n| `make codegen`  | Regenerate `generated/genqlient.go` from GraphQL operations      |\n| `make update-schema` | Re-introspect the live API, update schema, and run codegen  |\n| `make clean`    | Remove `./dist/`                                                 |\n\n### GraphQL Files\n\nThere are two distinct GraphQL files with different roles:\n\n| File | Role | Edited by |\n|------|------|-----------|\n| `graphql/schema.graphql` | Full copy of the server's type system — every type, enum, query, and mutation the backend exposes. Used by the code generator as a reference to validate operations and derive Go types. | Never — overwritten by `make update-schema` |\n| `graphql/operations.graphql` | The specific queries and mutations this CLI actually calls. A small, hand-authored subset of what the schema allows. | You, when adding new API calls |\n\nAt code-gen time (`make codegen`), genqlient validates every operation in `operations.graphql` against `schema.graphql` — referencing a field that doesn't exist on the server is a compile-time error. It then generates fully-typed Go functions into `generated/genqlient.go`.\n\n```\nschema.graphql        ← what the server CAN do  (generated, never edit)\noperations.graphql    ← what the CLI WANTS to do (hand-authored)\n        ↓\n    make codegen\n        ↓\ngenerated/genqlient.go ← type-safe Go functions  (generated, never edit)\n```\n\n### Adding a GraphQL Operation\n\nTo call a new backend endpoint from the CLI:\n\n**1. Check `graphql/schema.graphql`** to find the query or mutation name and its available fields. For example, to fetch ledgers:\n\n```graphql\n# In schema.graphql (for reference only — do not edit)\ntype Query {\n  ledgerList: [Ledger!]!\n}\ntype Ledger {\n  id: ID!\n  name: String!\n  ...\n}\n```\n\n**2. Add the operation to `graphql/operations.graphql`:**\n\n```graphql\nquery GetLedgerList {\n  ledgerList {\n    id\n    name\n  }\n}\n```\n\n**3. Run codegen** to generate the Go client function:\n\n```sh\nmake codegen\n```\n\nThis produces a `GetLedgerList(ctx, client)` function in `generated/genqlient.go` that you can call directly in your command code.\n\n**4. Use it in a command** (e.g. `cmd/ledgers.go`):\n\n```go\nclient := gqlclient.NewAuthenticatedClient(cfg.APIURL, creds.Token)\nresp, err := generated.GetLedgerList(cmd.Context(), client)\n```\n\n### Adding a New Command\n\n1. Create `cmd/\u003cname\u003e.go` implementing a `cobra.Command`\n2. Register it in `cmd/root.go` with `rootCmd.AddCommand(...)`\n3. Add any required GraphQL operations to `graphql/operations.graphql` (see above)\n4. Run `make codegen` to regenerate `generated/genqlient.go`\n\n### Updating the GraphQL Schema\n\nWhen the backend schema changes, re-introspect and regenerate the client:\n\n```sh\n# Against production (default)\nmake update-schema\n\n# Against local dev server\nBEANCOUNT_API_URL=http://localhost:4104/ make update-schema\n```\n\nRequires Python 3 (used by `scripts/introspection-to-sdl.py` to convert introspection JSON to SDL).\n\n### Project Structure\n\n```\nbeancount-cli/\n├── cmd/                  # Command implementations (login, logout, whoami)\n├── internal/\n│   ├── config/           # Environment variable config\n│   ├── credentials/      # Token storage (~/.beancount/credentials.json)\n│   └── gqlclient/        # Authenticated GraphQL HTTP client\n├── graphql/\n│   ├── schema.graphql    # Introspected server schema (auto-generated)\n│   └── operations.graphql# CLI GraphQL operations\n├── generated/\n│   └── genqlient.go      # Auto-generated type-safe GraphQL client\n├── scripts/\n│   └── introspection-to-sdl.py\n├── genqlient.yaml        # Codegen config\n└── Makefile\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstargately%2Fbeancount-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstargately%2Fbeancount-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstargately%2Fbeancount-cli/lists"}