diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-22 21:53:13 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-22 21:53:13 +0200 |
| commit | bbdbb32c28a7b37da8caee60cd3756720fe88f4f (patch) | |
| tree | 296073e6ab0bacef67a6cab1660f6b64b74f3085 /clients/bokfctl.c | |
| parent | 8e3ff5a7ae7cb5e43b6eed3be8d77f2997888669 (diff) | |
| download | bokf-df0f3eecf8cdfb3d450eb8a7a61e5d4d176cc637.tar.gz bokf-df0f3eecf8cdfb3d450eb8a7a61e5d4d176cc637.zip | |
reports: ignore IB rows on P&L accounts; bokfctl --dry-runv0.1.66
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'clients/bokfctl.c')
| -rw-r--r-- | clients/bokfctl.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clients/bokfctl.c b/clients/bokfctl.c index b5ecf47..47e42ac 100644 --- a/clients/bokfctl.c +++ b/clients/bokfctl.c @@ -19,6 +19,7 @@ static void usage(void) " --password PW login password (env BOKFD_PASSWORD)\n" " --token TOKEN API token instead of user/password (env BOKFD_TOKEN)\n" " --org ID active org for this request\n" + " --dry-run validate a mutating command without writing\n" " --version\n" "\n" "examples:\n" @@ -44,6 +45,7 @@ int main(int argc, char **argv) int64_t org = 0; const char *cmd = NULL; const char *args_json = NULL; + int dry_run = 0; for (int i = 1; i < argc; i++) { const char *a = argv[i]; @@ -88,6 +90,8 @@ int main(int argc, char **argv) return 2; } org = strtoll(val, NULL, 10); + } else if (strcmp(a, "--dry-run") == 0) { + dry_run = 1; } else if (strcmp(a, "--version") == 0) { printf("bokfctl %s\n", BOKF_VERSION); return 0; @@ -160,6 +164,28 @@ int main(int argc, char **argv) } } free(session); + if (dry_run) { + yyjson_mut_doc *md = yyjson_mut_doc_new(NULL); + yyjson_doc *qd = yyjson_read(req, strlen(req), 0); + yyjson_mut_val *root = qd ? yyjson_val_mut_copy(md, yyjson_doc_get_root(qd)) + : NULL; + char *out = NULL; + if (root && yyjson_mut_is_obj(root)) { + yyjson_mut_obj_remove_key(root, "dry_run"); + yyjson_mut_obj_add_bool(md, root, "dry_run", true); + yyjson_mut_doc_set_root(md, root); + out = yyjson_mut_write(md, 0, NULL); + } + yyjson_doc_free(qd); + yyjson_mut_doc_free(md); + free(req); + if (!out) { + fprintf(stderr, "bokfctl: request must be a JSON object\n"); + client_close(&conn); + return 2; + } + req = out; + } if (client_send_line(&conn, req) != 0) { fprintf(stderr, "bokfctl: send failed: %s\n", client_last_error()); free(req); |
