Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#!/usr/bin/env fish# ac-passphrase — request a passphrase from the slab menubar daemon.## Usage: ac-passphrase <label> [timeout-seconds]## Writes the secret to stdout on success, exits 0.# Writes nothing on cancel / daemon unavailable, exits non-zero.## The daemon caches by label (default 600s TTL) so repeated calls within# a deploy don't re-prompt. See slab/menubar-swift/README.md.set sock "$HOME/.ac-daemon.sock"if not test -S $sock echo "ac-passphrase: daemon socket not found at $sock" >&2 echo "ac-passphrase: is the slab menubar app running?" >&2 exit 2endif test (count $argv) -lt 1 echo "usage: ac-passphrase <label> [timeout-seconds]" >&2 exit 2endset label $argv[1]set timeout 600if test (count $argv) -ge 2 set timeout $argv[2]endset req (printf '{"op":"passphrase","label":%s,"timeout":%s}' \ (echo -n $label | jq -Rs .) $timeout)set resp (echo -n $req | nc -U $sock)if test -z "$resp" echo "ac-passphrase: empty response from daemon" >&2 exit 1endset ok (echo -n $resp | jq -r '.ok // false')if test "$ok" != "true" set cancelled (echo -n $resp | jq -r '.cancelled // false') if test "$cancelled" = "true" echo "ac-passphrase: cancelled" >&2 else set err (echo -n $resp | jq -r '.err // "unknown"') echo "ac-passphrase: $err" >&2 end exit 1endecho -n $resp | jq -r '.secret'