feat: expand main

This commit is contained in:
dualfroz committed 2026-09-06 19:26:45 +02:00
1 parent 668a5c093d
commit 1459f7fe37
1 file changed
+173
+173
View File
@@ -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 <host:port> remote-publish <channel> <message...> [--user NAME --pass PASS] [--token TOKEN]
\\ connect to a running `cobalt serve` and
\\ deliver <message> (joined from every
\\ trailing word) to every connection
\\ currently subscribed to <channel>; 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 <host:port> remote-subscribe <channel>[,channel...] [--user NAME --pass PASS] [--token TOKEN]
\\ connect to a running `cobalt serve` and
\\ block, printing "subscribed as <id>" on the
\\ first line, then "<channel>: <message>" 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 <id> ...` from a
\\ different terminal
\\
\\cobalt <host:port> remote-unsubscribe <subscriber-id> <channel>[,channel...] [--user NAME --pass PASS] [--token TOKEN]
\\ connect to a running `cobalt serve` and
\\ drop the listed channels from
\\ <subscriber-id> (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
\\ <subscriber-id> 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 <host:port> 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 <host:port> remote-ttl expire <key> <seconds> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-ttl persist <key> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-ttl ttl <key> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> 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 <host:port> remote-coll-ttl <kind> expire <name> <seconds> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll-ttl <kind> persist <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll-ttl <kind> ttl <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll-ttl sweep [--user NAME --pass PASS] [--token TOKEN]
\\ same operations as local `coll <kind>
\\ 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 <host:port> remote-coll counter get|set|incrby <name> [value|delta] [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll hash set|get|del <name> <field> [value] [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll hash len|getall <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll set add|rem|ismember <name> <member> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll set card|members <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll set inter|union <name> [name...] [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll set diff <name> <other> [other...] [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll list lpush|rpush <name> <value> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll list lpop|rpop|len <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll list range <name> <start> <stop> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset add <name> <member> <score> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset score|rank <name> <member> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset incrby <name> <member> <delta> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset rem <name> <member> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset card <name> [--user NAME --pass PASS] [--token TOKEN]
\\cobalt <host:port> remote-coll zset rangebyrank|rangebyscore <name> <lo> <hi> [--user NAME --pass PASS] [--token TOKEN]
\\ same operations as local `coll <kind> <op>`,
\\ 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 <host:port> remote-txn <script-file> [--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 <host:port> 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 <username> <password> readonly|readwrite|admin
\\ user passwd <username> <newpassword>
\\ user role <username> readonly|readwrite|admin
\\ user del <username>
\\ user list pre-requisite for `serve --auth`: create at
\\ least one admin user first
\\ backup <file> write a consistent point-in-time backup to <file>
\\ restore <file> replay a backup file into this database
\\ backup-info <file> validate a backup file and print its metadata
\\
\\ coll counter get|set|incrby <name> [value|delta]
\\ coll hash set|get|del <name> <field> [value]
\\ coll hash len|getall <name>
\\ coll set add|rem|ismember <name> <member>
\\ coll set card|members <name>
\\ coll set inter|union <name> [name...]
\\ coll set diff <name> <other> [other...]
\\ coll list lpush|rpush <name> <value>
\\ coll list lpop|rpop|len <name>
\\ coll list range <name> <start> <stop>
\\ coll zset add <name> <member> <score>
\\ coll zset score|rank <name> <member>
\\ coll zset incrby <name> <member> <delta>
\\ coll zset rem <name> <member>
\\ coll zset card <name>
\\ coll zset rangebyrank|rangebyscore <name> <lo> <hi>
\\ coll <kind> expire <name> <seconds> whole collection expires as one unit
\\ coll <kind> ttl <name> seconds left, -1 no expiry, -2 no such collection
\\ coll <kind> persist <name> clears expiry, collection immortal again
\\ coll expire-sweep reaps every due collection now, across all kinds
\\
\\ table put <table> <pk> [field=value ...]
\\ table get <table> <pk>
\\ table del <table> <pk>
\\ table scan <table>
\\ table select <table> [expr...] [--limit N] [--offset N]
\\ [--order-by field[:desc][,field[:desc]...]]
\\ expr is a predicate: <field> eq|ne|lt|lte|gt|gte|like <value>, 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:
\\ <field> in (<value> ...) is <field> eq v1 or <field> 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")
\\ <field> between <lo> and <hi> is <field> gte <lo> and <field> lte
\\ <hi> (inclusive both ends), e.g. age between i:18 and i:65,
\\ city in (s:oslo s:bergen s:trondheim)
\\ <field> is_null / <field> 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)
\\
;