From 1459f7fe372644556e8e29747c1859591e2bf3b5 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Sun, 6 Sep 2026 19:26:45 +0200 Subject: [PATCH] feat: expand main --- src/main.zig | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/src/main.zig b/src/main.zig index 93f22e9..fb9c4a4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -201,6 +201,179 @@ const usage = \\ rows are returned, walked in the same \\ partition-then-order sequence used to \\ compute them, not raw scan order; --range + \\ switches sum/avg/count/min/max to a RANGE + \\ frame (rows tied on `order` share the tie + \\ group's combined value instead of each + \\ accumulating its own, SQL's actual default; + \\ rejected together with row_number/rank/ + \\ dense_rank, same as local `table window`) + \\ - no local Db is opened; --user/--pass or + \\ --token authenticate first, same as + \\ `remote-select` + \\ + \\cobalt remote-publish [--user NAME --pass PASS] [--token TOKEN] + \\ connect to a running `cobalt serve` and + \\ deliver (joined from every + \\ trailing word) to every connection + \\ currently subscribed to ; prints + \\ how many subscribers it reached (0 is a + \\ normal outcome for a channel nobody is + \\ listening to, not an error) - no local Db + \\ is opened + \\ + \\cobalt remote-subscribe [,channel...] [--user NAME --pass PASS] [--token TOKEN] + \\ connect to a running `cobalt serve` and + \\ block, printing "subscribed as " on the + \\ first line, then ": " for + \\ every message published to any of the + \\ listed channels, until the connection + \\ closes (Ctrl+C, or the server shutting + \\ down) - the connection becomes receive-only + \\ once subscribed: to drop some of its + \\ channels without closing it, run + \\ `remote-unsubscribe ...` from a + \\ different terminal + \\ + \\cobalt remote-unsubscribe [,channel...] [--user NAME --pass PASS] [--token TOKEN] + \\ connect to a running `cobalt serve` and + \\ drop the listed channels from + \\ (printed by + \\ `remote-subscribe` when it started); prints + \\ how many channels were actually removed + \\ (naming one the subscriber was never on is + \\ harmless and does not count, not an + \\ error); an unknown or already-disconnected + \\ is reported as an error, + \\ not silently ignored; dropping every + \\ channel the subscriber still has ends that + \\ subscription outright, same as closing its + \\ connection - no local Db is opened + \\ + \\cobalt remote-user add|passwd|role|del|list [args] [--user NAME --pass PASS] [--token TOKEN] + \\ same operations as `user`, but against a + \\ running `cobalt serve` over the network + \\ instead of a local Db file - requires admin + \\ role if the server was started with --auth + \\ (--user/--pass or --token authenticate first) + \\ + \\cobalt remote-ttl expire [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-ttl persist [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-ttl ttl [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-ttl sweep [--user NAME --pass PASS] [--token TOKEN] + \\ same four operations as local `expire`/ + \\ `persist`/`ttl`/`expire-sweep`, but against a + \\ running `cobalt serve` over the network - + \\ `ttl` needs only readonly role, the other + \\ three need readwrite, if the server was + \\ started with --auth + \\ + \\cobalt remote-coll-ttl expire [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll-ttl persist [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll-ttl ttl [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll-ttl sweep [--user NAME --pass PASS] [--token TOKEN] + \\ same operations as local `coll + \\ expire|ttl|persist`/`coll expire-sweep`, but + \\ against a running `cobalt serve` over the + \\ network - `ttl` needs only readonly role, + \\ the other three need readwrite, if the + \\ server was started with --auth + \\ + \\cobalt remote-coll counter get|set|incrby [value|delta] [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll hash set|get|del [value] [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll hash len|getall [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll set add|rem|ismember [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll set card|members [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll set inter|union [name...] [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll set diff [other...] [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll list lpush|rpush [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll list lpop|rpop|len [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll list range [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset add [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset score|rank [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset incrby [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset rem [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset card [--user NAME --pass PASS] [--token TOKEN] + \\cobalt remote-coll zset rangebyrank|rangebyscore [--user NAME --pass PASS] [--token TOKEN] + \\ same operations as local `coll `, + \\ against a running `cobalt serve` over the + \\ network - read-only ops (get/len/getall/ + \\ ismember/card/members/inter/union/diff/ + \\ range/score/rank/rangebyrank/rangebyscore) + \\ need only readonly role, every other op + \\ needs readwrite, if the server was started + \\ with --auth + \\ + \\cobalt remote-txn [--user NAME --pass PASS] [--token TOKEN] + \\ same script format as local `txn`, but + \\ committed in one round trip against a + \\ running `cobalt serve` over the network - + \\ needs readwrite role if the server was + \\ started with --auth + \\ + \\cobalt remote-stats [--user NAME --pass PASS] [--token TOKEN] + \\ print a running `cobalt serve` instance's own + \\ request/rate-limit/auth/session counters + \\ together with its Db stats, as Prometheus + \\ text - the network counterpart of local + \\ `stats --prom`, since a server's own counters + \\ (distinct from its Db's) were otherwise only + \\ ever observable in-process + \\ + \\ user add readonly|readwrite|admin + \\ user passwd + \\ user role readonly|readwrite|admin + \\ user del + \\ user list pre-requisite for `serve --auth`: create at + \\ least one admin user first + \\ backup write a consistent point-in-time backup to + \\ restore replay a backup file into this database + \\ backup-info validate a backup file and print its metadata + \\ + \\ coll counter get|set|incrby [value|delta] + \\ coll hash set|get|del [value] + \\ coll hash len|getall + \\ coll set add|rem|ismember + \\ coll set card|members + \\ coll set inter|union [name...] + \\ coll set diff [other...] + \\ coll list lpush|rpush + \\ coll list lpop|rpop|len + \\ coll list range + \\ coll zset add + \\ coll zset score|rank + \\ coll zset incrby + \\ coll zset rem + \\ coll zset card + \\ coll zset rangebyrank|rangebyscore + \\ coll expire whole collection expires as one unit + \\ coll ttl seconds left, -1 no expiry, -2 no such collection + \\ coll persist clears expiry, collection immortal again + \\ coll expire-sweep reaps every due collection now, across all kinds + \\ + \\ table put [field=value ...] + \\ table get
+ \\ table del
+ \\ table scan
+ \\ table select
[expr...] [--limit N] [--offset N] + \\ [--order-by field[:desc][,field[:desc]...]] + \\ expr is a predicate: eq|ne|lt|lte|gt|gte|like , composed + \\ with "and"/"or"/"not" and parentheses, e.g. + \\ city eq s:oslo and not (age lt i:18) + \\ like matches SQL-style wildcards against a text field: "%" is any run + \\ of characters, "_" is exactly one, e.g. name like s:A%; it never uses + \\ an index even when the field is indexed (always a value scan) + \\ in and between are sugar over the operators above, so they use an + \\ index exactly where the desugared form would: + \\ in ( ...) is eq v1 or eq v2 or ... + \\ (a single value collapses to a bare eq, so it can use an index the + \\ same way eq does; two or more never do, same as any other "or") + \\ between and is gte and lte + \\ (inclusive both ends), e.g. age between i:18 and i:65, + \\ city in (s:oslo s:bergen s:trondheim) + \\ is_null / is_not_null take no trailing value; is_null + \\ matches a row where the field was never set OR set to an explicit + \\ none, e.g. city is_null and age gte i:18 (never uses an index, a + \\ sparse row's absence is not something a B-tree entry can represent) \\ ;