|
1 | 1 | # procountor |
2 | | -Procountor client |
| 2 | + |
| 3 | +Lightweight Go CLI for Procountor API operations. |
| 4 | + |
| 5 | +The CLI is a thin wrapper around: |
| 6 | +- `internal/apispec/procountor-api.yaml` |
| 7 | +- generated ogen client in `procountorapi/` |
| 8 | + |
| 9 | +External consumers can import the generated client directly: |
| 10 | + |
| 11 | +```go |
| 12 | +import "github.com/myyra/procountor/procountorapi" |
| 13 | +``` |
| 14 | + |
| 15 | +All API operations are exposed as explicit Kong commands, grouped by OpenAPI tag. |
| 16 | + |
| 17 | +## Build |
| 18 | + |
| 19 | +```bash |
| 20 | +go build ./... |
| 21 | +``` |
| 22 | + |
| 23 | +Run: |
| 24 | + |
| 25 | +```bash |
| 26 | +go run ./cmd/procountor --help |
| 27 | +``` |
| 28 | + |
| 29 | +## Authentication Model |
| 30 | + |
| 31 | +This CLI uses persisted login state by default. |
| 32 | + |
| 33 | +Run once: |
| 34 | + |
| 35 | +```bash |
| 36 | +procountor auth login |
| 37 | +``` |
| 38 | + |
| 39 | +`auth login` uses `--username`/`--password` (or `PROCOUNTOR_USERNAME`/`PROCOUNTOR_PASSWORD`) and prompts when needed, performs the `/login/companies -> /login` flow, and stores tokens in: |
| 40 | +- `$XDG_STATE_HOME/procountor/auth.json`, or |
| 41 | +- `~/.local/state/procountor/auth.json` when `XDG_STATE_HOME` is not set. |
| 42 | + |
| 43 | +The stored access token is automatically refreshed via `/token` when expired. |
| 44 | + |
| 45 | +Useful auth commands: |
| 46 | +- `procountor auth companies` |
| 47 | +- `procountor auth login` |
| 48 | +- `procountor auth refresh` |
| 49 | +- `procountor auth status` |
| 50 | +- `procountor auth logout` |
| 51 | + |
| 52 | +## Global Flags |
| 53 | + |
| 54 | +- `--base-url` or `PROCOUNTOR_BASE_URL`: API base URL. |
| 55 | + - Default: `https://nemo.procountor.com/api` |
| 56 | +- `--auth-file` or `PROCOUNTOR_AUTH_FILE`: override persisted auth state path. |
| 57 | +- `--timeout`: HTTP timeout (default `30s`). |
| 58 | +- `--verbose` / `-v`: print raw HTTP requests and responses to stderr. |
| 59 | + - Verbose output is dimmed when stderr is a terminal. |
| 60 | +- `--output`: output format (`human`, `json`, or `plain`, default `human`). |
| 61 | + |
| 62 | +Login credential env vars: |
| 63 | +- `PROCOUNTOR_USERNAME`: username for `auth companies` and `auth login`. |
| 64 | +- `PROCOUNTOR_PASSWORD`: password for `auth companies` and `auth login`. |
| 65 | + |
| 66 | +## Request Input |
| 67 | + |
| 68 | +Commands with request bodies use one of two primary models: |
| 69 | +- small or patch-shaped bodies use explicit flags |
| 70 | +- document-shaped create/replace bodies use command-specific whole-object import flags such as `--invoice`, `--ledger-receipt`, `--business-partner`, and `--cost-receipt` |
| 71 | + |
| 72 | +For flag-shaped commands: |
| 73 | +- top-level scalar and enum fields use normal flags |
| 74 | +- nested object fields use embedded sub-flags such as `--payment-info.bank-account` and `--options.receipt-name` |
| 75 | + |
| 76 | +Complex object arrays are not assembled through repeatable JSON flags. If you need to author or replace a nested list of objects, use the command's whole-document import flag instead. |
| 77 | + |
| 78 | +Whole-object import always uses an explicit command-specific flag. Bare stdin is never treated as an implicit whole request body. |
| 79 | + |
| 80 | +Use per-command help for the exact flag contract: |
| 81 | +- `procountor <group> <command> --help` |
| 82 | + |
| 83 | +Natural single-resource IDs are positional. Examples: |
| 84 | +- `procountor invoices get 12345` |
| 85 | +- `procountor ledger-receipts transactions update 12345 67890 --account 3000` |
| 86 | +- `procountor attachments content 555 --out attachment.pdf` |
| 87 | + |
| 88 | +## Binary Output |
| 89 | + |
| 90 | +Binary endpoints support `--out`: |
| 91 | +- `attachments content` |
| 92 | +- `invoices image` |
| 93 | + |
| 94 | +If `--out` is omitted, binary bytes are written to stdout. |
| 95 | + |
| 96 | +## Pagination |
| 97 | + |
| 98 | +Paginated search/list commands use `--paginate` and return only the result array (no `meta`/`nemoMeta` envelope). |
| 99 | + |
| 100 | +`--paginate` formats: |
| 101 | +- `<limit>` (same as `0:<limit>`) |
| 102 | +- `<from>:<limit>` |
| 103 | +- `all` |
| 104 | +- `<from>:all` |
| 105 | + |
| 106 | +Default: `--paginate 0:200` |
| 107 | + |
| 108 | +## Command Groups |
| 109 | + |
| 110 | +- `auth` |
| 111 | +- `attachments` |
| 112 | +- `business-partners` |
| 113 | +- `chart-of-accounts` |
| 114 | +- `company` |
| 115 | +- `cost-centers` |
| 116 | +- `cost-receipts` |
| 117 | +- `dimensions` |
| 118 | +- `fiscal-years` |
| 119 | +- `invoices` |
| 120 | +- `ledger-receipts` |
| 121 | +- `persons` |
| 122 | +- `products` |
| 123 | +- `reports` |
| 124 | +- `vats` |
| 125 | + |
| 126 | +Use per-command help for exact flags: |
| 127 | + |
| 128 | +```bash |
| 129 | +procountor <group> <command> --help |
| 130 | +``` |
| 131 | + |
| 132 | +## Schema |
| 133 | + |
| 134 | +Use `schema` with a command path to print that command's JSON request-body schema. |
| 135 | + |
| 136 | +Commands that do not send an `application/json` request body print nothing. |
| 137 | + |
| 138 | +```bash |
| 139 | +procountor schema invoices save |
| 140 | +procountor schema reports accounting |
| 141 | +``` |
| 142 | + |
| 143 | +## Examples |
| 144 | + |
| 145 | +```bash |
| 146 | +# One-time login (prompts for credentials) |
| 147 | +procountor auth login |
| 148 | + |
| 149 | +# Non-interactive login |
| 150 | +PROCOUNTOR_USERNAME=my-user PROCOUNTOR_PASSWORD=my-pass procountor auth login |
| 151 | + |
| 152 | +# Search invoices using stored auth |
| 153 | +procountor invoices search --status SENT --paginate 50 |
| 154 | + |
| 155 | +# Machine-readable JSON output |
| 156 | +procountor invoices search --status SENT --paginate 50 --output json |
| 157 | + |
| 158 | +# Get one invoice |
| 159 | +procountor invoices get 12345 |
| 160 | + |
| 161 | +# Save invoice from command-specific import flag |
| 162 | +procountor invoices save --invoice @./invoice.json |
| 163 | + |
| 164 | +# Update one ledger receipt transaction without roundtripping JSON manually |
| 165 | +procountor ledger-receipts transactions update 12345 67890 --account 3000 |
| 166 | + |
| 167 | +# Download invoice image |
| 168 | +procountor invoices image 12345 --format PNG --out ./invoice.png |
| 169 | + |
| 170 | +# Inspect company VAT defaults and a country VAT table |
| 171 | +procountor vats settings |
| 172 | +procountor vats country --country-code DK |
| 173 | + |
| 174 | +# Show auth status / clear local auth state |
| 175 | +procountor auth status |
| 176 | +procountor auth logout |
| 177 | +``` |
0 commit comments