luv

Workshop wiki

lobby.lisp

luvcraft/tools/lobby.lisp

system luvcraft/tools · 2 definitions · on GitHub

luv lobby: the tailnet value store from the shell.

`luv lobby put OPENAI_API_KEY` reads the value from stdin so secrets stay out of shell history; `luv lobby get KEY` prints it for $(...) use.

in-package#:luvcraft.tools
defunread-stdin-value

Everything on stdin, minus one trailing newline.

let
text
with-output-to-string
out
loopforline=
read-line*standard-input*nil
forfirst=tthennilwhilelinedo
unlessfirst
terpriout
write-stringlineout
text
defuncommand-lobby
arguments
let
verb
firstarguments
rest
restarguments
flet
one-key
unless
=1
lengthrest
command-line-error"lobby ~A expects exactly one KEY."verb
firstrest
cond
nullverb
command-line-error"lobby expects get|put|rm|ls|host."
string=verb"host"
formatt"~A:~D~%"
mqtt.net:lobby-host
mqtt.net:*lobby-port*
string=verb"ls"
loopfor
key.value
in
sort
mqtt.net:lobby-keys
#'string<:key#'car
do
formatt"~A~30T~D byte~:P~%"key
lengthvalue
string=verb"get"
let
value
mqtt.net:lobby-get
one-key
:default:absent
when
eqvalue:absent
format*error-output*"luv: no value stored under ~A.~%"
firstrest
write-stringvalue
terpri
string=verb"put"
unless
<=1
lengthrest
2
command-line-error"lobby put expects KEY [VALUE]; without VALUE it reads stdin."
let
when
zerop
lengthvalue
command-line-error"Refusing to store an empty value; use lobby rm to delete."
mqtt.net:lobby-put
firstrest
value
formatt"stored ~A (~D byte~:P) at ~A~%"
firstrest
lengthvalue
mqtt.net:lobby-host
string=verb"rm"
mqtt.net:lobby-delete
one-key
formatt"deleted ~A~%"
firstrest
t
command-line-error"Unknown lobby verb ~A; try get|put|rm|ls|host."verb